CDL Section 4 - Network Based APIs Flashcards
What is HTTP?
TCP-based protocol that is the foundation for communication on the internet.
REVIEW: Contents of an HTTP Request and Response
Request:
1. Request line - consists of request method, URI, and protocol version
- 0 or more HTTP headers - additional info about the target, like authentication
- Empty line - indicates the end of the headers
- Message body - contains actual data transmitted in the transaction
Response:
- Status line - protocol version, response code, and a human-readable phrase that summarizes the meaning of the code
- Zero or more HTTP headers - additional info about the response data
- Empty line - end of headers
- Message body - contains the response that’s sent with the transaction
What is a:
URI?
URL?
URN?
A URI (Uniform Resource Identifier) is a formal system for uniquely identifying resources and consists of two types: URLs (Uniform Resource Locator) and URNs (Uniform Resource Name).
A URL, also known as a web address, identifies a web resource as well as its location on a computer network and how to access it (e.g. http://www.library.pitt.edu).
A URN is a formal naming scheme that identifies a resource, but does not indicate its location or how to access it (e.g. ISBN, ISSN).
→ URI - the formal system that identifies a resource;
→ URL - tells where to find that resource
→ URN - identifies a resource via the naming scheme
What is an HTTP Status Code? What are the different options?
→ HTTP Status Codes - a predefined set of numerical codes that indicate the status of a specific HTTP request in the response header.
Separated into (5) classes:
○ 100 - informational ○ 200 - successful ○ 300 - redirection ○ 400 - client error ○ 500 - server error
What is an HTTP Header? What are the 4 types?
It is a list of key-value pairs that the client and server use to pass additional information or metadata between them in requests.
Headers can be HTTP-defined or defined by specific apps.
Header types are:
○ General headers - not specific to any kind of language
○ Request headers - carry info about the resource about to be fetched
○ Response headers - hold additional info about the response and the server providing it
○ Entity headers - contain info about the response body
What is HTTP Content Negotiation?
This is the process of selecting the best representation for a given response when there are multiple representations available - the language the response comes in (like English versus Spanish for example)
HTTP has several mechanisms for doing this – but they are typically done via “Accept Headers” .. “accept application/xml” versus “accept application/json” for example
What are the 2 most commonly used types of APIs?
RPC API - Remote Procedure Call
REST API
What is an RPC API?
These APIs will “call” a remote procedure located in a different address space similarly as to how it would call a procedure locally. A different address space can either be on a different computer or in a different network.
One computer calls code on another computer. The client sends a call to the server, usually with some parameters, and then waits for the server to return a reply message.
REVIEW: The Most common RPC Types
→ SOAP - “Simple Object Access Protocol” - considered an underlying layer of some of the more complex web services
- based on Web Services Description Language (WSDL).
- SOAP has strictly-defined syntax (i.e only uses XML) but supports many types of transfer protocols (such as HTTP for example)
→ JSON RPC - lightweight RPC protocol encoded in JSON. Very simple.
→ XML RPC - similar to SOAP, but is less structured and therefore has less constraints than SOAP
→ NETCONF - network device configuration management protocol that provides mechanisms to install, manipulate, and delete configurations on network devices
- also provides a mechanism for notification subscriptions and asynchronous message delivery
- NETCONF “servers” are usually just network devices like switches, routers, firewalls, etc.
→ gRPC - open source protocol developed by Google
What is a REST API? What are REST API’s optimized for use?
Is it a protocol?
Subset of web API architecture styles in which the endpoints represent resources. When a REST API is called, the server transfers a representation of the state of the resource to the client.
They are optimized for use on the Web.
NO - it is not a protocol.
REVIEW: In order for a web API to be considered “RESTful” it has to follow certain constraints:
- Client-Server relationship - the interface has to be decoupled from the app/consumer that is calling. All comms happen through the API interface.
- Cache-ability - HTTP responses on the web can be cached by client or server
- Layered System - a client making a request should not be able to tell if it’s connected directly to an end server or an intermediary agent (LB, proxy server, cache, etc.)
- Uniform Interface - follow a consistent and decouple interface for API calls. Majority of calls happen over HTTPS.
- Statelessness - every API call must contain everything needed to perform the entire operation. Nothing is remember by the server.
What is 1. a commonality and 2. a difference between XML-RPC & SOAP vs. REST?
Why is one preferred over the other when it comes to web-baed platforms?
They’re all designed to work over HTTP/HTTPS which is what they have in common.
XML and SOAP use a lot of text when making a request; very chatty.
REST uses the normal HTML Methods: GET/POST/PATCH/DELETE/etc. which makes things way easier and less complex and more efficient.
Because API’s are the building block of any platform, the ease of implementation with REST makes that method much more desirable than XML-RPC or SOAP.
What is Postman?
What are the benefits?
Postman is an API development environment that allows you to test, debug, monitor, document, and publish your APIs – easily make a request and examine the response.
It’s a simulation tool.
→ Postman simplifies testing and troubleshooting your API, so it can really speed up the API development process
What is a Variable in Postman?
When you create a variable, what components are specified?
They’re used to store dynamic information.
EX) you take an API request and input different variables to test and get different results. The variable in the request will get replaced with the matching variable value.
When you create a Variable, you specify:
- Initial Value
- Current Value
- Variable Name
What is an Environment in Postman?
An Environment is a set of variables and their corresponding values.
You can easily toggle between Environments which will change the associated variables when you make requests.