🪧 Vitrine.Dev | |
---|---|
✨ Nome | Financial API |
🏷️ Tecnologias | python, django, django-rest, postgresql |
🚀 URL | https://financial-rest-app.herokuapp.com/ |
🔥 Desafio | https://www.alura.com.br/challenges/back-end-4?host=https://cursos.alura.com.br |
- Django - O propósito do Django está no desenvolvimento de aplicações web e sites.
- Django Rest Framework - Desenvolvimento de web API'S de forma simples e ágil.
Make a [POST] Request at: https://financial-rest-app.herokuapp.com/register/ and get your Token !
Pretty DocYour control by:
- GET - Return Info
- POST - Insert Info
- PUT - Update Info
- DELETE - Delete Info
Create your account for Bearer Token Generate !
Request example:
[
{
"username": "john",
"password": "P4ssw0rd",
"password2": "P4ssw0rd",
"email": "johndoe@doe.com",
"first_name": "John",
"last_name": "Doe"
}
]
201 Return:
[
{
"username": "john",
"email": "johndoe@doe.com",
"first_name": "John",
"last_name": "Doe"
}
]
Bad Request:
[
{
"detail": "Registry already exists"
}
]
Access Token and Refresh Token Generator. Each 15 minutes you have to generate a new Access Token.
- /token/ [POST] Generate Access and Refresh Token. If you lose the refresh token, you'll have to generate another
P.S: Refresh Token expires in 1 day !
Request example:
[
{
"username": "john",
"password": "P4ssw0rd"
}
]
20x Return:
[
{
"refresh": "YOUR_REFRESH_TOKEN",
"access": "YOUR_ACCESS_TOKEN"
}
]
Bad Request:
[
{
"detail": "User and/or password incorrect"
}
]
- /token/refresh/ [POST]
Refresh the expired Access Token !
Request example:
[
{
"refresh": "YOUR_REFRESH_TOKEN"
}
]
20x Return:
[
{
"access": "NEW_ACCESS_TOKEN"
}
]
Bad Request:
[
{
"detail": "Invalid or expired Token",
"code": "token_not_valid"
}
]
- /token/verify/ [POST]
Verify the Access Token !
Request example:
[
{
"token": "YOUR_ACCESS_TOKEN"
}
]
200 Return:
[
{
}
]
Bad Request:
[
{
"detail": "Invalid or expired Token",
"code": "token_not_valid"
}
]
- Bearer Token
- Bearer "YOUR_ACCESS_TOKEN"
- /revenue/ [GET] Revenue List
- /revenue/ [POST] Insert a new Revenue
- /revenue/{pk}/ [PUT/DELETE] Update / Delete a Revenue
- /revenue/{yyyy}/{mm} [GET] List the filter revenue
- /revenue/?description= [GET] List the revenue description
Request example:
[
{
"description": "Revenue Description",
"value": 1000,
"date": "2000-12-25"
}
]
20x Return:
[
{
"id": "Revenue ID",
"description": "Revenue Description",
"value": 1000,
"date": "2000-12-25"
}
]
Bad Request:
[
{
"detail": "Registry already exists"
}
]
Categories Available: Food, Health, Home, Transport, School, Fun, Unexpected, Other
- Bearer Token
- Bearer "YOUR_ACCESS_TOKEN"
- /expense/ [GET] Expense List
- /expense/ [POST] Insert a new Expense
- /expense/{pk}/ [PUT/DELETE] Update / Delete a Registry
- /expense/{yyyy}/{mm} [GET] List the filter Expense
- /expense/?description= [GET] Expense by description
Request example:
[
{
"description": "Expense Description",
"value": 1000,
"category": "Food",
"date": "2000-12-25"
}
]
20x Response:
[
{
"id": "Expense ID",
"description": "Expense Description",
"category": "Expense Category",
"value": 1000,
"date": "2000-12-25"
}
]
Bad Request:
[
{
"detail": "Registry already exists"
}
]
Summary of the month with the % of expenses by category
- Bearer Token
- Bearer "YOUR_ACCESS_TOKEN"
- /summary/{yyyy}/{mm} [GET]
[
{
"Revenue/Month": 5000,
"Expense/Month": 2000,
"Final Value": 3000,
"Category": [
"Category: $500 - 50%",
"Another Category: $500 - 50%"
]
}
]
Bad Request:
[
{
"detail": "No registry"
}
]
pip install -r requirements.txt
- Create an `.env` file in the same folder where `migrate.py` is.
- In your terminal with venv, execute `python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'` generating a new secret key
- Insert the new secret key in `.env` file like this: `SECRET_KEY = oahsdodjifodjfodjfpadjpajsdpojsd` .
- Insert the database URL in the `.env` file like this: `DATABASE_URL = your_db://your_db:password@localhost/my_db`.
- Run `python manage.py migrate` and create the tables
python manage.py runserver
Server is running in http://127.0.0.1:8000/, access your browser !