Lesson 1: What’s and Why’s of APIs
What are APIs
APIs: Application Programming Interface
- refer to any method of communication between two entities of code
- connection points in code that allow one application to talk to another
Web API Protocols
Protocals: A set of rules for machines to speak the same language
OSI model: Open Systems Interconnection
Learn more about the OSI Model.
OSI Layers
Physical - Data Link - Network - Transport - Session - Presentation - Application (bottom to top)
- A layer servers the layer above it, and is served by the layer below it
- Protocols should be able to receive and hand off data for the protocols in the adjacent layers
Application layer protocols
HTTP, FTP, IMAP, SSH, POP, …
Two more layers: Web Service - Message Formatting
Web Service Layer
Simple Object Access Protocol (SOAP)
REpresentational State Transfer (REST): Use HTTP verbs
Message Formatting Layer
eXtensible Markup Language (XML)
JavaScript Object Notation (JSON)
REST Constraints
-
Client-Server
- Client sends requests to Server
- Server sends response to Client
-
Stateless
- A stateful architecture remembers a client’s activity between requests
- A truly RESTful architecture is not allowed to retain information about the state of another machine during the communication process
-
Cacheable
- Requests are labeled as cacheable or non-cacheable
-
Uniform Interface
- uniform between all clients and servers
-
Layered system
- a client can have access to an endpoint that relies on other endpoints without having to understand all of the underlying implementaions
- Layering allows very complicated tasks to be completed without having to understand all of the underlying complexities that are required to generate the response.
-
Code on Demand (optional)