2

A Brief Introduction to REST APIs

A Brief Introduction to REST APIs
09.03.2022
A REST API (known also as RESTful API) is an application programming interface (API) which uses HTTP requests to access the data. Usualy it uses 4 HTTP methods: GET, PUT, POST, DELETE to read, update, create or delete a resource.
An API is a collection of methods that allows two software applications to communicate and exchange data.
Rules of REST APIs:
1) REST is based on the resource name or noun. A URI of a REST API should always end with a noun.
2) HTTP methods are used to identify an action - GET, POST, UPDATE, DELETE
3) A web application must be organized into resources and HTTP verbs to modify those resources.
4) Always use plurals in URL for consitency
5) Send a correct HTTP code to indicate success or failure

Example of a simple REST API:
api/books GET Get all books
api/books/new GET Show form for adding new book
api/books POST Add a new book
api/books/1 PUT Update a book with id = 1
api/books/1/edit GET Show edit form for book with id = 1
api/books/1 DELETE Delete a book with id = 1
api/books/1 GET Get a book with id = 1

In building an RESTful API, 6 REST arhitectural constraints must be taken into consideration:
1) Uniform Interface. All the resources must be uniquely identified through an URL, and only by using methods such as DELETE, PUT, GET, POST someone can access a resource. It should be a unique way of interacting with a server, independent of the device type or application.
2) Stateless. All operations must be stateless and all state management must take place on the client, not the server.
3) Cacheable. All resources should allow caching
4) Client-Server. A clear distinction between client and server must exist. For example, UI is a concept in the client's domain and data access and security in the server's domain.
5) Layered System. REST allows for an architecture composed of multiple layers of servers.
6) Code on demand. Usualy, the server will send to the client resources in the form of JSON but when necessary, servers can send back executable code to the client.

OPTI Systems makes the process of creating an API straightforward by following these steps:
1) Determine the client’s requirements. We analyze functional and nonfunctional requirements and determine what exactly the API needs to do, the expected performance and response time and concerns with regard to data protection.
3) Developing the API. OPTI has highly skilled developers and will implement the API in the shortest time and in a cost effective manner.
4) Testing the API. The goal of testing the API is to make sure it works under different conditions and the security meets the highest possible standards
5) Publish the API.
6) Monitor the API. After testing and launching we will monitor your API to understand how it is being used and how it performs.

Latest

Announcements

Find more of our latest software development tutorials, launch announcements, and career opportunities.
Read our blog