Basic API to see the pokemons and their types
- See, create and delete pokemons
- Create types of pokemon
- User authentication
- Register and verify users
First you must make sure you have PostgreSQL installed
After that, you should:
-
First you need to have a virtual environment
-
Clone the repository from Github and switch to the new directory:
git clone https://github.com/SSleimann/pokeapi.git cd pokeapi
-
Activate the virtualenv for your project and install project dependencies:
pip install -r requirements.txt
-
Set the environment variables
DJANGO_DEBUG=True DJANGO_SECRET_KEY=yourmegasecretpassword DATABASE_URL=postgres://user:password@host:port/db
-
Apply the migrations:
python manage.py migrate --settings=pokeapi.settings.local
-
Now you can run the server:
python manage.py runserver --settings=pokeapi.settings.local
GET /pokemon/{pokename}/
Displays information about the pokemon
GET /pokemon/
Shows all types of pokemon. You can also paginate: /pokemon/?limit=100&offset=400
GET /pokemon/all_types/
Shows all types of pokemon
GET /accounts/{user}/
Display user information
POST /pokemon/create_poke/
Create a pokemon. Expected fields:
- name, description, type name, height, weight and picture
POST /pokemon/create_type/
Create a type of pokemon. Expected fields:
- name and description
POST /accounts/login/
Login user and returns a token. Expected fields:
- email and password
POST /accounts/signup/
Register a new user. Expected fields:
- username, email, first_name, last_name, password and password_confirmation
POST /accounts/verify/
Verify a new user. Expected fields:
- token
DELETE /pokemon/{pokename}/
Delete a pokemon
PUT and PATCH /pokemon/{pokename}/
Update or partially update the pokemon. Expected fields:
- name, description, type name, height, weight and picture
PUT and PATCH /accounts/{user}/
Update or partially update the user. Expected fields:
- username, email, first_name and last_name
PUT and PATCH /accounts/{user}/profile/
Update or partially update the user profile. Expected fields:
- picture
In this example, a POST request is made to the /accounts/login/
route with the email and the password. Then the content of the request is decoded, the json is obtained and then the token is obtained.
A GET request is made to the /pokemon/all_types
route, the authorization header is set with a token, and the data is returned.