DEV Community


Posted on

What is API & REST API ?

An API, or Application Programming Interface, is set of rules i.e. protocols for building and interacting with software application.
It allows different software systems to communicate with each other, enabling them to share data and functionality.
An example of an API is the Facebook API, which allows developers to access and interact with functionality of the Facebook platform such as posting status updates, retrieving user information, and managing ad campaigns. Another example is the Google Maps API, which allows developers to embed maps and location-based functionality in their own websites and apps.
How an API Works:
APIs acts as a bridge between applications and web servers, processing data transfer between systems. When a client application initiates an API call, also known as request, it is sent to the web server via the API's Uniform Resource Identifier(URI) and includes a request verb, headers and sometimes a request body. The API then processes the request and may make a call to an external program or web server for the requested information.
The server responds with the requested data, which the API then forwards to the initial requesting application. This process of requests and responses all happens through the API. Unlike user interfaces which are designed for human use, APIs are designed for use by computers or applications.

REST API: Representational State Transfer
REST is a type of web architecture and a set of constraints to be used when creating web services. RESTful API is API that conforms to the REST architectural style and constraints, it is typically used to make requests to retrieve or update data on a web server. A RESTful API uses HTTP requests to POST(create), PUT(update), GET(read), and DELETE(delete) data. A RESTful API also returns a response in a standard format, typically JSON or XML, and uses standard HTTP status codes to indicate the status of the request. RESTful APIs are popular because they are simple to understand and easy to use, and they work well with the HHTP protocol that the internet is built on. Additionally, RESTful APIs are often faster and more lightweight than their SOAP(Simple Object Access Protocol) counterparts because they use smaller message formats. RESTful API's have become a popular way for systems to expose databases through HTTP(s) following CRUD operations(Create, Read, Update, Delete), and return JSON or XML as responses, it's also widely used in microservices, mobile and web applications, IoT
and many more.
REST requires that a client make a request to the server in order to retrieve or modify data on the server.
A request generally consists:

  • An HTTP verb, which defines what kind of operation to perform.

  • A header, which allows the client to pass along information about the request.

  • A path to a resource.

  • An optional message body containing data.

Top comments (0)