REST API
WHAT IS API?
An API, or
application programming interface, is a collection of rules governing how programs
and devices connect to and communicate.
API= Application Programming Interface
WHAT
IS REST API?
REST APIs
are the most often used approach for linking components in microservices
systems since they are versatile and lightweight. A REST API is an API that
adheres to the REST, or representational state transfer, architectural style's
design principles.
REST = Representational State Transfer. REST
API is also known as RESTful API.
REST defines
four interface constraints:
- Identification of resources
- Manipulation of resources
- Self-descriptive messages
- Hypermedia as the engine of application state
REST
framework requires the following:
- Python (3.6,3.7,3.8,3.9,3.10)
- Django (2.2,3.0,3.1,3.2,4.0)
- PostMan
REQUIRED
PACKAGES:
We need to
install packages to start the process.
- Django (pip install Django)
- Django rest framework (pip install djangorestframework)
- Django cors headers (Django-cors-headers)
BENEFITS
OF REST API:
- Scalability
- Flexibility and portability
- Independence
Now let’s create the Django project open the cmd in the
desired folder and type the command Django-admin start
project DjangoAPI(project name).
File created
Let’s open the visual studio code inside the
project path.
Now run the project just type: python manage.py runserver http://127.0.0.1:8000/
Now let’s
create one app enter: python manage.py startapp
Employee(enter app name).
App created successfully. Now add the app name in the setting.py
Now create the required models for the app, we need two
models for this app
- Departments
- Employees
Now create the database, and install SqLitestudio for creating databases. Open
SqLiteStudio and choose the folder and create the database.
After creating the database we need to create serializers (serializers.py)
Enter the URL configurations in URL.py
Enter the URL in POSTMAN and select GET, PUT, DELETE, POST.
CONCLUSION:
A REST API is an application programming interface that
conforms to the REST architectural style requirements and allows interaction
with RESTful web services.
Comments
Post a Comment