Skip to content

PicolotoLF/olympic-history-athletes

Repository files navigation

Olympic History Athletes API

Setup

Environment Variables

Setup the environments variables:

DJANGO_SETTINGS_MODULE=olympic_history_athletes.envs.dev;

KAGGLE_USERNAME={kaggle_username};

KAGGLE_KEY={kaggle_key}

obs: To generate Kaggle credentials: https://github.com/Kaggle/kaggle-api

Running Migrations

After created your virtual environment with virtualenv, in the directory of the project enter the commands:

pip install -r requirements.txt

python manage.py makemigrations

python manage.py migrate

python manage.py runserver

obs: The database still out of data

Tasks

To run the routine to get the csv from Kaggle and populate the database, it necessary run the command:

python manage.py process_tasks

The tasks will be schedule to run everyday inserting 50 new objects.

Methods

Update

To UPDATE some object use the PUT http method:

PUT https://olympic-history-athletes.herokuapp.com/api/{category}/{id}/

Example:

PUT https://olympic-history-athletes.herokuapp.com/api/sport/1

payload:

{"name": "car"}

Delete

To DELETE some object use the DELETE http method:

DELETE https://olympic-history-athletes.herokuapp.com/api/{category}/{id}/

Example:

DELETE https://olympic-history-athletes.herokuapp.com/api/sport/1

Insert

To CREATE some object use the DELETE http method:

POST https://olympic-history-athletes.herokuapp.com/api/{category}

Example:

POST https://olympic-history-athletes.herokuapp.com/api/sport

payload:

{"name": "test"}

Filtering Attributes

To filter attribute make a request to endpoint /api/?name=

Example:

https://olympic-history-athletes.herokuapp.com/api/sport/?name=Judo

Filtering Athletes

To filter athlete make a request to endpoint /api/athletes_search?

Not work searching by the parameter id, just for the name.

It's able to put multiple filter.

Example:

https://olympic-history-athletes.herokuapp.com/api/athletes_search?medal=Silver&season=Summer

Available filters:

  • games
  • team
  • season
  • city
  • sport
  • event
  • medal

About

Django API

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors