CDL Section 4 - Network Based APIs Flashcards

1
Q

What is HTTP?

A

TCP-based protocol that is the foundation for communication on the internet.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

REVIEW: Contents of an HTTP Request and Response

Request:
1. Request line - consists of request method, URI, and protocol version

  1. 0 or more HTTP headers - additional info about the target, like authentication
  2. Empty line - indicates the end of the headers
  3. Message body - contains actual data transmitted in the transaction
A

Response:

  1. Status line - protocol version, response code, and a human-readable phrase that summarizes the meaning of the code
  2. Zero or more HTTP headers - additional info about the response data
  3. Empty line - end of headers
  4. Message body - contains the response that’s sent with the transaction
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a:

URI?
URL?
URN?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is an HTTP Status Code? What are the different options?

A

→ 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an HTTP Header? What are the 4 types?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is HTTP Content Negotiation?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the 2 most commonly used types of APIs?

A

RPC API - Remote Procedure Call

REST API

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is an RPC API?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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.

A

→ 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a REST API? What are REST API’s optimized for use?

Is it a protocol?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

REVIEW: In order for a web API to be considered “RESTful” it has to follow certain constraints:

  1. Client-Server relationship - the interface has to be decoupled from the app/consumer that is calling. All comms happen through the API interface.
  2. Cache-ability - HTTP responses on the web can be cached by client or server
A
  1. 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.)
  2. Uniform Interface - follow a consistent and decouple interface for API calls. Majority of calls happen over HTTPS.
  3. Statelessness - every API call must contain everything needed to perform the entire operation. Nothing is remember by the server.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Postman?

What are the benefits?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a Variable in Postman?

When you create a variable, what components are specified?

A

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:

  1. Initial Value
  2. Current Value
  3. Variable Name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is an Environment in Postman?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the Code Generator in Postman?

A

This is a tool that allows you to create code snippets, which you can then reuse in your actual app.

EX) After you have tested and verified that your API behaves as intended, you can incorporate the created API calls in your client application.

17
Q

Are API calls good for tracking events or changes in an application?

If not, what is?

A

NO

Webhooks

18
Q

What is a Webhook?

A

Tools that allow you to react to events and changes in an application. They are commonly referred to as a “reverse API” or a “web callback.”

While APIs perform synchronous requests, Webhooks will use the server to Asynchronously notify the client about the changes.

19
Q

How do Webhooks work?

Is it a Push or Pull methodology?

A

Instead of the client creating a request toward the server, a client subscribes to a specific Webhook.

Regular APIs and polling is a “Pull” method i.e they pull info to themselves, whereas Webhooks are a “Push” method because they push a change once detected to the client/entity.

20
Q

How are Webhook notifications transported to subscribers?

A

HTTP POST request/method