What is REST API ?

Techno Freak
4 min readAug 16, 2022

--

Representational State Transfer (REST)

Rest is a software architectural style that helps in implementing Web services. The web services which are implemented using the REST architectural style is known as RESTFUL web services.

REST technology is generally preferred to the more robust Simple Object Access Protocol (SOAP) technology because REST uses less bandwidth, simple and flexible making it more suitable for internet usage. It’s used to fetch or give some information from a web service. All communication done via REST API uses only HTTP request.

REST API

In HTTP there are five methods that are commonly used in a REST-based Architecture i.e., POST, GET, PUT, PATCH, and DELETE. These correspond to create, read, update, and delete (or CRUD) operations respectively.

GET: The HTTP GET method is used to read (or retrieve) a representation of a resource. GET returns a representation in XML or JSON and an HTTP response code of 200 (OK). In an error case, it most often returns a 404 (NOT FOUND) or 400 (BAD REQUEST).

  • POST: The POST verb is most often utilized to create new resources. In particular, it’s used to create subordinate resources. On successful creation, return HTTP status 201, returning a Location header with a link to the newly-created resource with the 201 HTTP status.
  • PUT: It is used for updating the capabilities. In other words, if the PUT is to a URI that contains the value of a non-existent resource ID. On successful update, return 200 (or 204 if not returning any content in the body) from a PUT.
  • DELETE: It is used to delete a resource identified by a URI. On successful deletion, return HTTP status 200 (OK) along with a response body.
  • PATCH: It is used to modify capabilities. The PATCH request only needs to contain the changes to the resource, not the complete resource.

Benefits of REST API

  1. Lightweight: They rely on the HTTP standard, which means it’s format-agonistic and you can use XML, JSON, HTML, etc. This makes REST APIs fast, and lightweight — which is necessary for mobile app projects, internet of things devices, and more.
  2. Independent: REST APIs is the fact that the client and server are independent. In other words, the REST protocol separates the data storage and the UI from the server.
  3. Flexibility and portability: The indispensable requirement for data from one of the requests to be properly sent, it is possible to perform a migration from one server to another or carry out changes on the database at any time. Front and back can therefore be hosted on different servers, which is a significant management advantage.

Best Practices to be used while developing a API

  1. Use JSON as the Format for Sending and Receiving Data.
  2. Go with Error Status Codes.
  3. Use nesting on endpoints to show relationships
  4. Don’t use Verbs in URLS
  5. Use SSL(Secure Sockets Layer)for Security .
  6. Be clear with the Versioning.
  7. Use filtering ,sorting and pagination to retrieve the Requested data.

How can I Develop a Rest API (Perquisites)

  • Install your development platform according to its product documentation.
  • Familiar with OAuth 2.0, which requires some setup.
  • Familiar with curl, the tool used to execute REST requests in this quick start. If you use another tool, you should be familiar enough with it to translate the example code.
  • Familiar with JSON or be able to translate samples from JSON to the standard you use.
  • Enable an SSL endpoint in your application server.

Best Frameworks to create your REST APIs

Django: Python is a general-purpose language. It has a wide range of applications from Web development (like Django and Bottle).Django itself is an amazing framework for developing web applications. You can get up to speed really quickly, just by following the tutorials on their website. It also comes with really cool built-in features, so creating an API is usually really easy.

Slim :It’s a PHP micro framework that helps you to quickly write simple yet powerful web applications and Restful APIs. You can use it as the back-end web service to support some Angular JS front-end apps. Slim uses a simple concept for its middleware.

Spring boot: Spring boot is built for fast prototyping. The boot is just a thin configuration layer over Spring Framework, as such it inherits all the strengths of Spring.

Flask: Flask is the lightweight choice for developing REST APIs in python. It has very little impact on system resources and provides very easy methods to provide information as HTTP endpoints in a format easy to read by the recipient. It also includes HTML templating.

Ruby on Rails: There are many third-party plugins (Ruby gems) available for Rails development. Ruby has a very clean syntax that makes code easier to both read and write than more traditional Object Oriented languages, such as Java.

ASP .NET Core : Majority of the cloud systems are clusters of smaller machines that get jobs distributed to them and work together to provide a highly available system.

Happy learning and exploring !!!!!

--

--

Techno Freak

Devops &Full-Stack enthusiast . Helping People to learn about cloud and opensource . Learning bit by bit