REST API by Crio.Do : #LearnbyDoing

Yogita Misal
4 min readFeb 2, 2021

Ever wondered how

  • Paytm or similar mobile apps make payments from Flipkart. Does Flipkart have Paytm’s code to do that?
  • Google Sign-in works on websites like medium.com. Does Google share their user data with Medium?
  • Web applications for facebook, twitter or gmail fetch data from their backend servers

And Yay! I know How whole things happen. Excited to know right? Let’s go in-depth with REST API. I’m sure you will learn something exciting.

API stands for Application Programming Interface, and unfortunately, people will ask you the meaning of each word here. An API is like a waiter in a restaurant. You don’t go into a cafe and walk straight into the kitchen to tell the chef what you wanna eat. The waiter does that for you, and that’s exactly what an API is — with the client being you, the customer and any resource that can send data, being the chef.

Now, these APIs have different styles, or in more formal terms — conventions and architectures about how they are used.

REST APIs are those APIs which follow the guidelines set by the REST architecture. They follow a client-server model where one software program sends a request and the other responds with some data. REST APIs commonly use the HTTP protocol to send requests & receive responses.

How an API request differs from a usual HTTP request for a webpage, is in terms of the data returned. HTTP requests for webpages return HTML, CSS & JavaScript files which are rendered by the browser and displayed to the user. But, in the case of APIs, the request can be for any data (not just webpage) and the response is read by the requesting program which interprets the data.

JSON (JavaScript Object Notation — how cryptic :| ) is a standard format that is easily “understandable” by applications and can be handled well in most languages. So the data format in REST is usually JSON. For example, an Android app can effortlessly utilize data sent by a Node.js server. XML is another popular format for data transfer between applications.

Excited about trying this out on your own? Use https://www.metaweather.com/api/location/search/?query=san or find one you like from here

Which ones did you try out? (You can try out a Chrome extension like JSONView to format the JSON response in your browser window)

As we discussed earlier, REST API calls are made on top of the HTTP protocol. We can analyse the network packets during the API calls to confirm this using Wireshark.
Wireshark is a popular network analysis tool to capture network packets and display them at a granular level. Once these packets are broken down, you can use them for real-time or offline analysis.

The client sends a HTTP GET request (line 8) to the server. The server responds with a 200 status code and JSON data on line 10. (API request was made to http://jsonplaceholder.typicode.com/posts, see doc)

Conclusion :

Thus we have studied how the API looks and How things work in real-life scenarios.

Links for reference

  1. Understanding & using REST APIs
  2. HTTP vs REST
  3. REST Guidelines
  4. Metaweather API Documentation
  5. Installing Wireshark on Ubuntu
  6. Capturing HTTP network packets using Wireshark

PS: This is my first and favorite article from Crio.do which actually excited me to stepped into development. I don’t know before How REST API actually works? Crio.do taught me How things work in a real-life scenario.

The Crio Winter of Doing is providing people with learning by doing approach, which is a very good way of learning things. During the First Stage, I learned the basics of many technologies by implementing it in real-time. This article is a very small part of CWoD’s Stage 1 REST Bytes and it was my first #LearnbyDoing experience. I’m learning by doing in the Crio Winter Of Code and looking forward to more of such #learnbydoing experiences. Thanks Crio.do.

Learn by Doing ,Micro-Experience,Crio.Do

  • #ShareYourLearning
  • Do visit below website to explore the new things .

https://www.crio.do

Please don’t forget to clap, It will help me to bring more ideas to share with you all. Thanks for reading!

--

--