Flutter and APIs

Know Everything that you need to About APIs

Kushal Goel
FlutterFever
Published in
2 min readMay 15, 2021

--

Hear πŸ‘‚ every Developer πŸ‘¨πŸ»β€πŸ’» next to you talking about APIs and you sitting in the corner Clueless 😨 about what they are? No problem 😌. FlutterFever to the rescue here.

Backend API - Photo by Ian Battaglia on Unsplash

Note: If Reading Articles is not your Cup of Tea ️️️🍡, you can check it out in a more Visual & Eye β€” Pleasing format here.

Forget those long intros, let's jump into it Straight !!

An Application Programming Interface or an API is a way for Two Computers to Talk to Each Other via the Internet.

This Communication follows a Set of Rules, which are already defined by various Design Protocols like :

  • REST (Most Common)
  • GraphQL
  • SOAP
  • XML-RPC
  • JSON-RPC

RESTful APIs

A RESTful API Divides the Data into Groups each with a Unique Endpoint on the Server (URI). It consists of 4 Main Methods that are :

  • GET - To Read/Query Data from the Database
  • POST - To Create/Add new Data to the Database
  • PATCH - To Update some Data on the Database
  • DELETE - To Delete/Remove some Data from the Database

It all starts with a Client Request, which consists of a REST Method, the Endpoint & the Headers with information about Authentication and other MetaData. Following is the Body, usually in JSON format.

The Server then Responds with a Status Code, Headers with Meta Data about the Server, and the Body containing Response Details.

Status Codes

  • 1** - Some Information/Warning
  • 2** - Successful Request & Response
  • 3** - Redirect
  • 4** - Client Side Error (Request)
  • 5** - Server Side Error

QnAs

Q) But, how to interact with APIs in a Flutter App ?

A) To do this, you can use packages like http and dio to communicate with Servers and use APIs !!

Q) Okay, so are there any free APIs to try and start learning?

A) Yes, there are many free APIs. Some of them are -

  • Jokes API
  • Coinbase API
  • Shrtcode API

This was all about APIs. I hope you learned something new. Thanks a lot for your precious time & I will see you in the next article !!

FlutterFever is an Immersive Environment for High-Quality Flutter Tutorials, Resources, Tips & Tricks to Build, Deploy and Market Beautiful and Performant Flutter Apps Effortlessly. Find more about it here.

--

--

Kushal Goel
FlutterFever

Passionate Developer πŸ‘¨πŸ»β€πŸ’» & Love to Explore New Technologies πŸ“±