HomeBytesheetsUI TemplatesUI ToolsRoad MapsStack DiscussionByte Camp

Query Params

No.KeyValue
1

Body

What is REST API?

REST (Representational State Transfer) APIs are a set of architectural principles used for creating web services. They provide a standardized approach for clients to communicate with servers over HTTP, enabling the exchange of data in various formats, typically JSON or XML.

Types of REST APIs

  • GET: Retrieves data from the server. It is a safe and idempotent operation, meaning multiple identical requests have the same effect as a single request Learn more.
  • POST: Sends data to the server to create a new resource. It is not idempotent, as multiple identical requests may create multiple resources Learn more.
  • PUT: Updates existing data on the server. It replaces the entire resource or creates it if it does not exist. It is idempotent Learn more.
  • DELETE: Removes data from the server. It is idempotent Learn more.
  • PATCH: Partially updates existing data on the server. It modifies specific fields of a resource. It is not always idempotent Learn more.

Components of REST Requests

  • Request Body: Contains data sent to the server, often in JSON or XML format for POST and PUT requests. It defines the content or payload of the request Learn more.
  • Cookies: Store data on the client-side, sent with each request to the server if applicable. They are commonly used for session management, authentication, and tracking.
  • Query Parameters: Additional data appended to the URL for filtering, sorting, or pagination purposes. They are commonly used in GET requests and appear after the question mark (?).
  • Status Codes: Indicate the outcome of the server's attempt to fulfill the request. They are three-digit numeric codes sent by the server in the response header. Common status codes include 200 (OK), 404 (Not Found), 500 (Internal Server Error), etc Learn more.
  • Headers: Provide additional information about the request or response, such as content type, authorization, caching directives, etc. Common headers include Content-Type, Authorization, Accept, and Cache-Control Learn more.

    1. Content-Type: Specifies the media type of the request body, such as application/json or application/xml. It informs the server about the format of the data being sent.
    2. Authorization: Contains credentials used to authenticate the client with the server. It can include tokens, API keys, or basic authentication credentials.
    3. Accept: Specifies the desired media types that the client is willing to accept in the response. It helps the server determine the most appropriate representation format.
    4. Cache-Control: Controls caching behavior, allowing the client or intermediary caches to store or revalidate responses. It includes directives like max-age, no-cache, and must-revalidate.