API
API
1 | const express = require("express"); |
API
- API: Application Programming Interface
- GUI and API:
GUI (Graphical User Interface) and API (Application Programming Interface) are integral components of software systems, with a close interconnection in facilitating user interaction and system functionality. GUIs serve as the visual interface through which users interact with software, offering intuitive controls and visual feedback. APIs, on the other hand, define the methods and protocols for communication between different software components, allowing seamless integration and interaction. The connection between GUI and API lies in their collaboration: GUIs utilize APIs to access and manipulate underlying functionalities, abstracting away the complexity of implementation details. This integration enables developers to design user-friendly interfaces while leveraging the power and flexibility of underlying systems through standardized interfaces provided by APIs. Thus, GUIs and APIs work in tandem, with APIs serving as the bridge that connects the user-facing interface of the GUI to the underlying functionality of the software system.
POST MAN
Postman is a popular collaboration platform for API development used by developers and teams to simplify the process of building, testing, and managing APIs. It provides a user-friendly interface for sending HTTP requests, testing APIs, and viewing responses in various formats like JSON and XML. Postman allows users to create and organize collections of API requests, share them with team members, and collaborate on API development projects. It also offers features for automating tests, monitoring APIs, and documenting APIs with detailed descriptions and examples. Overall, Postman streamlines the API development process and enhances productivity for developers and teams.
post man is not for:
- user interation
- performance testing]
- security testing
HEADERS
meta information, some more additional information.
In the context of HTTP (Hypertext Transfer Protocol), a header is a part of a request or response sent between a client (such as a web browser) and a server. Headers contain additional information about the data being transmitted, such as metadata or instructions for handling the request or response.
HTTP headers consist of key-value pairs, where the key represents the header name and the value represents the data associated with that header. There are several types of headers, including:
- Request Headers: These are sent by the client to provide additional information about the request being made. Common request headers include “User-Agent” (providing information about the client making the request), “Accept” (indicating the media types that the client can understand), and “Authorization” (used for authentication purposes).
- Response Headers: These are sent by the server in response to a request and provide additional information about the server’s response. Common response headers include “Content-Type” (indicating the media type of the response body), “Content-Length” (specifying the length of the response body in bytes), and “Cache-Control” (providing caching directives).
initial value & current value
To edit an environment variable, select the variable and change any of the following:
Variable - The name of the variable. Use the name to reference the variable in requests and scripts.
Type - If you select default, the variable value is visible in plain text. If you select secret, the variable value is masked. Learn more about variable types.
Initial value (shared) - This value is synced to your account using Postman’s cloud servers. It’s shared with any collaborators who have access to the environment. It’s also made public when publishing an environment along with a collection. If the value includes sensitive data, such as a password or key, you can mask the value by selecting the secret variable type.
Current value (local) - This value is used when sending requests in your local instance of Postman. It’s never synced to your account or shared with your team unless you choose to persist it. If you leave the current value blank, the initial value is copied to the current value when you save the environment.
it might contain some privacy information like password and stuff.
Query Parameters
read documentation of the API
query parameters are available can only be know by reading the API documentation.
Path Variables
- Path Variables:
- Path variables are placeholders within the URL’s path segment.
- They are used to identify specific resources or endpoints.
- Path variables are typically used for fetching or manipulating a specific resource.
- Path variables are part of the URL’s path and are specified directly in the URL structure.
- Example:
/books/{bookId}
, where{bookId}
is a path variable representing a specific book’s identifier.
- Query Parameters:
- Query parameters are key-value pairs appended to the end of a URL after a question mark (
?
). - They are used to provide additional information to an endpoint or to filter/query data.
- Query parameters are commonly used for searching, filtering, sorting, or pagination purposes.
- Query parameters do not affect the structure of the URL path and are appended to the URL after a
?
, separated by&
if there are multiple parameters. - Example:
/books?genre=fiction&author=John+Doe
, wheregenre
andauthor
are query parameters used to filter the list of books.
- Query parameters are key-value pairs appended to the end of a URL after a question mark (
API authentication
POST
Json format
1 | { |
Random input data
1 | { |
PATCH request
to update order
put the update inf in Body
JSON-> javascript object notation, its key value pairs
write API
GET : request data
POST: create a resource
PUT : update a resource
DELETE: delete a resource
1 | from flask import Flask, request, jsonify |