First Steps to APIs

Uvindu Dharmawardana
3 min readJul 17, 2019

--

This post is about basic concepts about APIs and how it performs.Further more you can get a basic idea about REST APIs as well….

First let’s see what is an API..?

API stands for Application Programming Interface.main purpose of API is that providing a communication medium for separate applications or services by using set of rules.This will help applications to communicate between each other.

How API works…?

Let’s assume that you are at a restaurant and you want to order a food, but the problem is you don’t have any connection with kitchen, so you can call the waiter and give the order to the waiter, and the waiter will give that order to REST(Representational State Transfer)the kitchen and deliver you the order from the kitchen. And that’s a real life example of API, API is like the waiter in this case, it do the same work between two applications, it will deliver the request between the applications and let those applications to talk each other.

Types of API…

There are four main types of APIs..

1.Open APIs -: also known as public APIs, There are no restrictions to access these APIs, Open APIs are free to access everyone.

2.Partner APIs -: Needs specific kind of rights or licence to access these APIs because these APIs are not free to everyone. These are private APIs.

3.Internal APIs -: Also known as private APIs.These APIs are only exposed by the internal systems.

4.Composite APIs -: This type of APIs contains different data and services.

There are several more APIs to talk about, those are..

  • SOAP
  • XML-RPC
  • JSON-RPC
  • REST

SOAP(Simple Object Access Protocol)

This protocol uses XML format to transfer data. It’s main purpose is define the structure of messages and methods of communication. It uses WSDL(Web Server Definition Language) to publish a definition of it’s interface.

XML-RPC

XML-RPC uses specific type of XML format to transfer the data. This is also older than SOAP.XML-RPC using minimum bandwith and also it is much more simple than SOAP.

JSON-RPC

This is similar to XML-RPS. Difference is JSON-RPC is using JSON as the format to transfer the data.

REST(Representational State Transfer)

This is one of the main API types using right now. Definition of REST API is that which is using HTTP requests to GET,POST,PUT and DELETE the data.

All the API’s are depend on requests and the URL’s which are passing through the API’s called requests and the data receiving back is called response.

Structure Of a Request

  • The endpoint
  • The method
  • The headers
  • The body

The Endpoint -:

The endpoint the requesting URL. and root-endpoint is the starting point of the API requesting for.

And the root-endpoint is the starting point of the url.

The Method -:

The method is the type of request you want to send to the server. And it has five types of requests.

  • GET — to get a resource from a server
  • POST — send data to a server
  • PUT — update data in a server
  • DELETE — delete data in a server
  • PATCH — same like PUT, update a resource in a server

The Headers -:

HTTP Headers are used to provide information to both server and users. It can be used to many purposes such as authentication and stuff like that.

The Body(The Data) -:

This contains the data or the information which is sending to the server.

HTTP Status Codes and Error Messages

  • 200+ -: This means request is succeeded.
  • 300 + -: This means request redirected to another URL.
  • 400 + -: This means error from client has occurred.
  • 500+ -: This means error from server has occurred.

--

--

Uvindu Dharmawardana
Uvindu Dharmawardana

Written by Uvindu Dharmawardana

B.Eng Software Engineering University of Westminster

No responses yet