1. Business

Rest API :A Detail Guide About ?

Disclaimer: This is a user generated content submitted by a member of the WriteUpCafe Community. The views and writings here reflect that of the author and not of WriteUpCafe. If you have any complaints regarding this post kindly report it to us.

REST API  (Representational State Transfer) is an architectural style for designing networked applications. REST API (Application Programming Interface) is a set of rules or conventions for building and interacting with web services that adhere to the principles of REST.

In a REST API, resources (such as data objects) are identified by URLs (Uniform Resource Locators), and clients can interact with these resources using standard HTTP methods, such as GET, POST, PUT, PATCH, and DELETE, to perform operations on the resources. REST APIs commonly use the JSON (JavaScript Object Notation) or XML (eXtensible Markup Language) format for data exchange.

Here's a detailed guide about REST API:

  1. Resource: In REST, a resource is an object or piece of data that can be accessed via a URL. For example, a REST API for a blog system may have resources such as /posts for blog posts, /comments for comments on blog posts, and /users for user information.
  2. HTTP Methods: REST APIs use standard HTTP methods to perform operations on resources. The most commonly used HTTP methods in REST APIs are:
  • GET: Retrieves the representation of a resource. It is used to retrieve data from a resource without modifying it.
  • POST: Creates a new resource. It is used to submit data to a resource to create a new object or record.
  • PUT: Updates an existing resource or creates a new resource if it does not already exist. It is used to modify data in a resource or create a new resource if it does not already exist.
  • PATCH: Partially updates an existing resource. It is used to modify only a portion of the data in a resource, rather than replacing the entire resource.
  • DELETE: Deletes a resource. It is used to remove a resource or object. 

 

       3.URL (Uniform Resource Locator): In REST, resources are identified by URLs. URLs are used to uniquely identify a resource and specify the location of the resource in the system. For example, a URL for a blog post resource could be: https://api.example.com/posts/12345, where 12345 is the unique identifier for the blog post.

      4.Request and Response: REST APIs use HTTP requests and responses to communicate between clients (such as web browsers or mobile apps) and servers (which host the resources). Clients make requests to perform operations on resources, and servers respond with the requested data or status information. Requests and responses usually contain data in a standardised format, such as JSON or XML.

        5 .Stateless: REST is stateless, which means that each request from a client to a server must contain all the information needed to understand and process the request. The server does not store any information about the client's state between requests, and each request is treated as an independent operation.

         6 . Authentication and Authorization: REST APIs may require authentication and authorization to ensure that only authorised clients can access or modify resources. Authentication is the process of verifying the identity of a client, while authorization determines what actions a client is allowed to perform on a resource based on their authenticated identity.

     7. HATEOAS (Hypermedia as the Engine of Application State): HATEOAS is a constraint of REST that allows clients to navigate the available resources and actions through hyperlinks embedded in the responses. 

          8.This means that clients do not need to have prior knowledge of the API structure, but can discover and interact with resources dynamically by following hyperlinks in the responses.

    9.Documentation: REST APIs should be well-documented to provide clear guidelines on how to interact with the API, including the available resources, supported HTTP methods, data formats, authentication and authorization requirements, error handling, and any other relevant information for developers who want to use the API.

Login

Welcome to WriteUpCafe Community

Join our community to engage with fellow bloggers and increase the visibility of your blog.
Join WriteUpCafe