Lecture 4 - Postman & API Flashcards
1
Q
GET Request
A
- Requests data from a specified resource (typically used to retrieve data from a server).
- Query strings are sent in the URL.
/test/demo_form.php?name1=value1&name2=value2
- Can be cached, bookmarked, and remains in browser history.
- Should not be used for sensitive data.
- Restrictions on the datatype: only ASCII characters allowed.
- Has length restrictions and is used only to request data, not modify it.
2
Q
POST Request
A
- Sends data to a server to create or update a resource.
- Data is stored in the request body.
- Not cached, does not remain in browser history, and cannot be bookmarked.
- No length restrictions.
3
Q
GET vs POST
A
- GET can be cached and bookmarked; POST cannot.
- GET has length and data type restrictions; POST does not.
- GET data is visible in the URL, making it less secure; POST data is not visible.
4
Q
Other Requests
A
-
PUT:
- Sends data to create or update a resource.
- Idempotent: multiple identical requests result in the same outcome.
-
HEAD:
- Similar to GET but without the response body.
- Useful for checking what a GET request will return without downloading the content.
-
DELETE:
- Deletes the specified resource.
-
PATCH:
- Applies partial modifications to a resource.
-
OPTIONS:
- Describes communication options for the target resource.
-
CONNECT:
- Establishes a two-way communication tunnel with the requested resource.
-
TRACE:
- Performs a message loop-back test to test the path for the target resource, useful for debugging.
5
Q
REST API
A
- A REST API (Representational State Transfer Application Programming Interface) is a web service that uses the principles and constraints of REST architecture to enable interaction between clients and servers. (A standard way of getting information that is running on a server.)
- RESTful APIs are designed to be stateless, scalable, and easily accessible, allowing clients to perform CRUD (Create, Read, Update, Delete) operations on resources using standard HTTP methods.
6
Q
Key Concepts of REST API
A
-
Resources:
- Resources are the objects or entities that the API interacts with, such as users, products, or orders. Each resource is identified by a unique URL.
-
Stateless:
- Each request from a client to the server must contain all the information needed to understand and process the request. The server does not store any client context between requests.
-
Client-Server Architecture:
- The client and server are separate entities that communicate over a network. The client makes requests, and the server processes them and returns responses.
-
Uniform Interface:
- A consistent and standardized way of interacting with resources. This typically includes using standard HTTP methods and status codes, and a predictable structure for URLs.
-
Representations:
- Resources can have multiple representations (e.g., JSON, XML). Clients and servers exchange these representations to perform operations on the resources.
7
Q
Benefits of REST API
A
- Scalability: Statelessness and separation of client and server enhance scalability.
- Flexibility: Can handle multiple types of calls, return different data formats, and support multiple versions.
- Simplicity: RESTful APIs use standard HTTP methods, making them easy to understand and implement.
- Performance: The stateless nature can improve performance by reducing the server load.