This document provides an overview of REST APIs, including:
1. What is an API and how it connects different platforms and applications.
2. What is a REST API and the key architectural constraints it follows including being stateless, cacheable, having a uniform interface, and using a layered system.
3. An overview of HTTP as the most popular protocol for REST APIs and how it uses verbs like GET, POST, PUT, and DELETE to make requests.
2. Content
1. What is an API
2. What is a REST API
3. REST Architectural Style
i. Architectures
ii. Overview of HTTP
iii. Message Formats
4. How to use REST APIs
3. What is an API
API - Application Programming Interface
API is a contract. A promise to perform described services when
asked in specific ways.
App
4. Its a set of functions, classes or objects that software module
exposes for other programs to use by passing arguments (inputs).
Usually API’s are used
to connect the two
different platforms
What is an API
7. What is a REST API
REST - Representational State Transfer
REST is simply an architectural style achieved by combining a number of
different well-known architectures.
It be used to modify or view resources on the server without
performing any server-side operations.
14. Overview of HTTP
The most popular protocol used for RESTful implementations is HTTP.
REST architecture use HTML Verbs to make requests.
HTML Verbs - uniquely address data using a uniform and minimal set of
commands.
• GET - Read data or resources.
• POST - Create data or resource.
• PUT - Update data or resources.
• DELETE - Delete data or resources.
15. Message Formats
REST is not tied to a specific
message format.
• XML - Extensible Markup
Language
• JSON - JavaScript Object
Notation
<?xml version="1.0" encoding="UTF-8"?>
<Person>
<Name>Matt</Name>
<Surname>Van Der Westhuizen</Surname>
<Hobbies>
<Hobby>Boardgames</Hobby>
<Hobby>GameDev</Hobby>
<Hobby>Reading</Hobby>
</Hobbies>
<PhoneNumbers>
<PhoneNumber>
<Type>home</Type>
<Number>1234567890</Number>
</PhoneNumber>
<PhoneNumber>
<Type>cell</Type>
<Number>0821234567</Number>
</PhoneNumber>
</PhoneNumbers>
</Person>
{
"name": "Matt",
"surname": "Van Der Westhuizen",
"hobbies": [
"Boardgames",
"GameDev",
"Reading"
],
"phoneNumbers": [
{"type": "home", "number": "1234567890"},
{"type": "cell", "number": "0821234567"}
]
}
16. How to use REST APIs
Here is some examples in Google Map API
https://maps.googleapis.com/maps/api/geocode/json?&address=pitakotte
Extrogene Software Pvt Ltd. Place ID = ChIJS2KQ2d5b4joR4vOh1RaicjQ
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJS2
KQ2d5b4joR4vOh1RaicjQ&key=AIzaSyBXMUhoE8lu0wjm7SCO9RacyKE-
ef8J0Gw
Client Server: This constraint provides separation of concerns, improves scalability and improves the portability of the interface.
Stateless: This constraint requires that each request contains sufficient state for the server to understand what to do... this provides visibility, readability and scalability.
Cacheable: This constraint requires that all responses from the service to its clients are explicitly labelled as cacheable or non-cacheable so that intermediary servers or components can cache responses. This improves efficiency, scalability and user-perceived performance.
Uniform Interface: This constraint defines a simple standard for working with a REST service. It includes identification of resources by URI, manipulation of resources through representation, self-descriptive message and HATEOAS.
Layered System: This constraint requires that a client should not be able to tell if it is connected to the end server or to an intermediary. Layered systems cause a reduction in performance, but this should be counteracted by caching.
Layered System: This constraint requires that a client should not be able to tell if it is connected to the end server or to an intermediary. Layered systems cause a reduction in performance, but this should be counteracted by caching.