/MobileGameRestAPI

A REST API in django for a mobile game

Primary LanguagePython

MobileGameRestAPI

A REST API in django for a mobile game

Install

  1. Install python3 (apt-get install python3)
  2. Install pip3 (apt-get install python3-pip)
  3. Install virutalenv (python3 -m venv env)
  4. Activate the environment (source env/bin/activate)
  5. Install requirements (pip install -r requirements.txt)

When you are done, use: deactivate to exit the virutal environment.

To update requirements just run step 6 again.

Add new requirements

  1. Activate the environment (source env/bin/activate)
  2. Install the package using pip
  3. run pip freeze --local > requirements.txt

Deployment

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04

Access the API (Token auth)

Generate a token

  1. Create a user (python manage.py createsuperuser).
  2. Go to localhost:8000/admin and log in with your user.
  3. Go to the table "Tokens".
  4. Press "Add token".
  5. Choose your user an press "SAVE".

You should now see a token that look like: "02ffe8c6c2851ccc8b458e39049d6b4f94be5a25"

Access the browsable API

  1. Go to localhost:8000/admin and log in with your user.
  2. Go to localhost:8000 and you should now have access to the api.

Access the API using curl

Scores example

Get all scores

Add new score