API How It Works With Practical Examples

List Of Content

ADS Area (CARBON)

ADS Area (CARBON)

 

Getting Started 

RESTFUL API (Application Programming Interface) is a Standard Way for data manipulation and exchanging between a server and a client, for example, you are going to create an application that gets the Trending Tweets in a specific region and shows them as the tweets of the day, for that you use the Twitter API For fetching those tweet from the server (database). RESTFUL APIs are based on CRUD (Create, Read, Update and Delete) which works for submitting, changing and removing data.

We are going to see a very nice demo where we have a server running on top of Node.js and a Client app where it has the ability to fetch a list of the available Pokemon from the Server and Edit or Add Pokemon using RESTFUL API available on Github.

Using API

Now How actually APIs Works is by Sending an HTTP Request contains some attributes related to the data you want to query, where the server is going to receive the request and handle it (for ex: fetch Pokemon from the database), then the Server send a Response back to the Client contains the Data he asked for (Queried Data) and the client must have the appropriate handlers of the data is going to be received in order to parse it and use it efficiently.

Most of the Times API Send and Receive a JSON Structured data since it is very lightweight and easy to parse also the security concerns about using JSON data exchanging (Use JWT Authentication).

Try to Clone the pokemons-api repository and since it is running on top of node.js make sure that you have it installed on your machine then run the Server First, you can use Postman where it is going to allow you to send requests and parse the responses (API Testing).

So we have the most basic one is getting the list of the available pokemons from the server /pokemonsList  and we need to send a GET Request 

 

Where it is the Same Thing for Adding or Removing Pokemons, but in this particular case you need to provide either the pokemon's name and ability in case of adding or only the name for removing a Pokemon using x-www-form-urlencoded In Postman for submitting the data

So API gonna help you a lot to achieve better data management for your app, also for the ability to use it for different platforms since your data is stored on a remote server and you are using a RESTFUL API To manage this data.

Also, keep in mind of using Authentication for securing your data access and restriction, you can take a look at the JWT Authentication Technique.

Share Tutorial

Made With By

Ipenywis Founder, Game/Web Developer, Love Play Games