Skip to content

🏎️ API in django-rest-framework made for a vehicle registration system with authentication.

License

Notifications You must be signed in to change notification settings

rychardbarros/Django-RestFramework-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Django-RestFramework-API

🚘 API in django-rest-framework made for a vehicle registration system with authentication.

Python Django SQLite Swagger DjangoRest JWT Postman

Introduction

Welcome to the official documentation of the Vehicle Management REST API! This API was developed using the Django-Rest-Framework and aims to provide endpoints for creating, reading, updating and deleting vehicle records. Through this documentation, you will learn how to interact with the API, how to make the most of its functionalities and how to explore its features in an interactive way. Overview

The Vehicle Management API follows the principles of REST architecture, allowing communication between systems in an efficient and standardized way. It provides an interface to interact with the "Vehicle" entity, allowing you to perform CRUD (Create, Read, Update, Delete) operations on these records.

A notable feature of this API is the integration of Swagger, an interactive documentation tool, which allows developers to explore and test endpoints in an intuitive way. In addition, the use of ReDoc offers a simplified and visually appealing documentation experience.

Installation

  1. Clone the repository:
git clone https://github.com/rychardbarros/Django-RestFramework-API.git
cd Django-RestFramework-API
  1. Create and activate a virtual environment (optional but recommended):
pip install virtualenv
python -m venv venv

# On Windows
venv\Scripts\activate

# On Linux/Mac
source venv/bin/activate
  1. Install the dependencies:
install -r requirements.txt

To run the Django-RestFramework-API, follow the steps below:

Open a terminal or command prompt. Navigate to the directory:

cd path/to/the/Django-RestFramework-API

Start the crud:

python manage.py runserver

Authentication

To access the API resources, it is necessary to authenticate. Authentication is done through the use of JWT tokens (JSON Web Tokens), which are obtained through the authentication endpoints.

Obtaining a Token:

    URL: /token/
    Method: POST
    Parameters:
        {
          "username": "admin",
          "password": "admin"
        }
    Response:
        {
          "access": "your_access_token",
          "refresh": "your_refresh_token"
        }

Token Renewal:

    URL: /token/refresh/
    Method: POST
    Parameters:
      refresh: Refresh previously obtained token
      {
        "access": "new_access_token"
      }

Endpoints

The main API endpoints are listed below:

Vehicle Listing

URL: /api/cars/
Method: GET
Permission: authenticated
Success Response:
[
  {
    "id_vehicle": "vehicle_id",
    "model_vehicle": "vehicle_model",
    "manufacturer_vehicle": "vehicle_manufacturer",
    "release_year": "year",
    "status": "vehicle_status",
    "description": "vehicle_description"
  }
]

Vehicle Details

URL: /api/cars/{id_vehicle}/
Method: GET
Permission: authenticated
Success Response:
[
  {
    "id_vehicle": "vehicle_id",
    "model_vehicle": "vehicle_model",
    "manufacturer_vehicle": "vehicle_manufacturer",
    "release_year": "year",
    "status": "vehicle_status",
    "description": "vehicle_description"
  }
]

Creating a Vehicle

URL: /api/cars/
Method: POST
Permission: authenticated
parameters:
  {
    "model_vehicle": "vehicle_model",
    "manufacturer_vehicle": "vehicle_manufacturer",
    "release_year": "year",
    "status": "vehicle_status",
    "description": "vehicle_description"
  }
Response:
[
  {
    "id_vehicle": "vehicle_id",
    "model_vehicle": "vehicle_model",
    "manufacturer_vehicle": "vehicle_manufacturer",
    "release_year": "year",
    "status": "vehicle_status",
    "description": "vehicle_description"
  }
]

Upgrading a Vehicle

URL: /api/cars/{id_vehicle}/
Method: PUT/PATCH
Permission: authenticated
Parameters:
  {
    "model_vehicle": "new_vehicle_model",
    "manufacturer_vehicle": "new_vehicle_manufacturer",
    "release_year": "new_year",
    "status": "new_vehicle_status",
    "description": "new_vehicle_description"
  }
Response:
[
  {
    "id_vehicle": "vehicle_id",
    "model_vehicle": "new_vehicle_model",
    "manufacturer_vehicle": "new_vehicle_manufacturer",
    "release_year": "new_year",
    "status": "new_vehicle_status",
    "description": "new_vehicle_description"
  }
]

Deletion of a Vehicle

URL: /api/cars/{id_vehicle}/
Method: DELETE
Permission: authenticated
Success Response:
  {
    "message": "Vehicle deleted successfully"
  }

Layout

Swagger interface:

Postman for Token:

Endponit test with swagger:

Interactive Documentation

You can also explore the API interactively using Swagger and ReDoc. Simply access the following links:

Swagger: Swagger Documentation

Through these interfaces, you can experiment with the API endpoints, send requests and visualize the responses in an intuitive way.

License πŸ“š

MIT license.

Made by Rychard Barros

About

🏎️ API in django-rest-framework made for a vehicle registration system with authentication.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages