DEV Community

Soham
Soham

Posted on

Complete API Guide

APIs have become the center of software
development,
connecting and transferring data to
millions of applications every day.
The guide covers simple explanations of all basic
concepts of APIs as well as the most common HTTP
status code and, more
importantly, a list of popular
APIs that you can use to improve your applications.
API stands for
What is API?
_Application Programming Interface. _
It’s a connection between computers or
between computer programs. It is a type of
software interface, offering a service to other
pieces of software.
Basically, it enables apps to exchange data
and functionality easily and securely.
It let your product or service communicate
with other products or services without
having to know how they’re implemented.
Example
Imagine you’re sitting at a table in a
restaurant with a menu of choices to order
from. The kitchen is the part of the “system”
that will prepare your order.
What is missing is the critical link to
communicate your order to the kitchen and
deliver your food back to your table.
That’s where the waiter or API comes in. The
waiter is the messenger – or API – that takes
your request or order and tells the kitchen –
the system – what to do. Then the waiter
delivers the response back to you; in this
case, it is the food.
Workflow of API
APIs sit between an application and the web
server, acting as an intermediary layer that
processes data transfer between systems.

  1. A client application initiates an API call to retrieve information also known as a request.
  2. After receiving a valid request, the API makes a call to the external program or web server. This request is processed from an app to the web server via the API’s Uniform Resource Identifier (URI) and includes a request verb, headers, and sometimes, a request body. How an API works? 01
  3. The server sends a response to the API with the requested information.
  4. The API transfers the data to the initial requesting application.

How an API works?

While the data transfer will differ depending
on the web service being used, this process
of requests and response all happens
through an API.
Whereas a user interface is designed for use
by humans, APIs are designed for use by a
computer or application.
REST API Architecture 01
REST relies on a client and server approach
which separates front and back ends of the
API, & provides considerable flexibility in
development and implementation.
This means the implementation of the client
and the
implementation of the server can be
done independently without each knowing
about
the other.
The REST architecture is the most popular
approach to build APIs.
REST stands for

Representational State Transfer.
REST API Architecture 02
cli!nt who r!qu!t for th! r!ourc!
!rv!r who ha th! r!ourc!
A Restful system consists of a
API that adh!r! to REST principl! ar!

call!d RESTful.
By uing a REST int!rfac!, diff!r!nt cli!nt hit
th! am! REST !ndpoint, p!rform
th! am!
action, and r!c!iv! th! am! r!pon!.

In th! REST archit!ctur!, cli!nt !nd
r!qu!t to r!tri!v! or modify r!ourc!, and

!rv!r !nd r!pon! to tho! r!qu!t.
REST API Architecture 03
REST requires that a client make a request to
the server in order to retrieve or
modify data
on the server.
A an HTTP verb, which defines what kind of
operation to perform

A a header, which allows the client to pass
along information about the request

A a path to a resource

A an optional message body containing
data

A request generally consists of:

CRUD 01
CRUD Stands for

Create Read Update Delete
In a REST environment, CRUD often

corresponds to the HTTP methods

GET, POST, PUT/PATCH, and DELETE.
Create POST
Read GET
Update PUT / PATCH
Delete DELETE
CRUD 02
In regards to its use in RESTful APIs, CRUD is
the standardized use of HTTP Action Verbs.
This means that if you want to create a new
record you should be using “ ”.

If you want to read a record, you should be
using “ ”. To update a record use “ ” or
“ ”, And to delete a record, use “ .”
POST
GET PUT
PATCH DELETE
Let’s learn about HTTP verbs, There are many
HTTP verbs we use in requests to interact with
resources in a
REST system:
HTTP Verbs 01
HTTP defines a set of request methods to
indicate the desired action to be
performed for a given resource.
These request methods are referred to as
HTTP Verbs.
Below are the various types of HTTP Verbs
GET
The GET method is used to retrieve specific
resource. Requests using GET should only
retrieve data and should have no other

effect on the data.
HTTP Verbs 02
HEAD
POST
Same as GET, but doesn’t have a messagebody in the response. The HEAD method is
useful in recovering meta-data that is
written according to the headers, without
transferring the entire content.
A POST request is utilized to send data to a
server to create a resource, for example,
customer information, file upload, etc.
usually using HTML Forms.
HTTP Verbs 03
PUT
DELETE

PUT is similar to POST as it is used to send
data to the server to create or update a
resource. The difference between it
replaces all current representations of the
target resource with the uploaded content.
As it sounds, the DELETE request method is
used to delete resources indicated by a
specific URI. Making a DELETE request will
remove the targeted resource.
HTTP Verbs 04
CONNECT
OPTIONS
CONNECT request establishes a tunnel to
the server identified by a specific URI. A
good example is SSL tunneling.
The OPTIONS method requests permitted
communication options for a given URL or
server. A client can specify a URL with this
method, or an asterisk (*) to refer to the
entire server.
HTTP Verbs 05
TRACE

The TRACE method performs a message
loop-back test along the path to the target
resource, to provide a useful debugging
mechanism.

It allows clients to view whatever message
is being received at the other end of the
request chain so that they can use the info
for testing or diagnostic functions.
HTTP Verbs 06
PATCH
PUT vs PATCH
The PATCH method is used for making
partial changes to an existing resource.

The PATCH method provides an entity
containing a list of changes to be applied
to the resource requested using the URI.

PUT method uses the request URI to supply
a modified version of the requested
resource which replaces the original
version of the resource, whereas the PATCH
method supplies a set of instructions to
modify the resource.
HTTP Status Codes 01
Status codes are issued by a server in
response to a client’s request made to

the server.
The first digit of the status code specifies
one of five standard classes of responses.
Standard Classes
Informational responses
Successful responses
Redirection responses
Client error responses
Server error responses
1xx
2xx
3xx
4xx
5xx
HTTP Status Codes 02
It indicates that the request was received
and understood by the server and its
continuing the process.
1xx - Informational responses
Continue
Switching Protocols
Processing
Early Hints
100
101
102
103
HTTP Status Codes 03
It indicates that the action requested by
the client was received, understood, and
accepted
2xx - Successful responses
OK
Created
Accepted
Non-Authoritative Information
No Content
200
201
202
203
204
HTTP Status Codes 04
Many of these 3xx status codes are used in
URL redirection or it indicates the client
must take additional action to complete
the request.
3xx - Redirection responses
Moved Permanently
Found
Not Modified
Use Proxy
Temporary Redirect
Permanent Redirect
301
302
304
305
307
308
HTTP Status Codes 05
This status code is intended for situations in
which the error seems to have been
caused by the client.
4xx - Client error responses
Bad Request
Unauthorized
Forbidden
Not Found
Not Acceptable
Request Timeout
400
401
403
404
406
408
HTTP Status Codes 06
It indicates that the server has
encountered a situation where it doesn’t
know how to handle a request.
5xx - Server error responses
Internal Server Error
Not Implemented
Bad Gateway
Service Unavailable
Gateway Timeout
HTTP Version Not Supported
500
501
502
503
504
505
HTTP Status Codes 07
These were not all the status codes that
exists, there are many more status codes
that indicates different things.
You can find and learn more about http
status codes on this , with detailed
information about that stauts code.
website
Useful Freemium APIs on
rapidapi.com
Travel Advisor
Google Search
Open Weather Map
Bayut (real estate)
Bing News Search
Movie Database
API-NBA
video
video
video
video
video
Useful Free APIs on
rapidapi.com
Coinranking
Flight Data
COVID-19
Currency Exchange
URL Shortener Service

RAWG Video Games Database
Edamam Food and Grocery DB
video
Thank you so much

Top comments (0)