API
Django Rest Framework
API (Application Programming Interface)
An Api is a software intermediary that allows two or more applications to talk to
each other
API types in terms of release Policies
● Private: It can be used within the organization
● Partner: It can be used within Business Partners.
● Public: It can be used by any third party Developers.
Google Maps API
Application
LinkedIn Uplers
Your Website
Naukri Indeed
Web
API
Application DB
Django
REST & RESTful APIs
● REST is an architectural Design to develop a Web
API.
● It stands for Representational State Transfer.
● API’s which are developed using this architecture are
called as REST or RESTful APIs.
How REST API works:
● Client makes an HTTP request to API
● API will communicate to your Web Application or
database if needed.
● From which data will be provided to the API.
● API returns this response data to the client.
CRUD operations in REST:
Student API Resource (End Point):
https://qspiders.com/api/students
1 2 3
1. Base URL
2. Naming Convention
3. Resource of API (End Point)
Example of Student API Resource (End Point):
● GET - /api/students
● GET - /api/students/1
● POST - /api/students
● PUT - /api/students/1
● PATCH - /api/students/1
● DELETE - /api/students/1
Data Conversion:
● In API’s we always pass JSON string.
● So first we should learn the conversion of Data.
Model Instance Python Native Data JSON Data
s = Student.objects.get(id=1) List, Dictionary, List of Dictionary Ex: ‘{“name”:”John” , ”roll”:23}’
Serialization Rendering
into JSON