building4theweb / soundem-api

RESTful API for demo application developed at BFTW

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

soundem-api Deploy

Running Locally

Install requirements

$ pip install -r requirements.txt

Create .env

Create a .env in the root of the project based on sample.env.

Populate database with sample fixture

$ python manage.py populate_db

Run development server

$ python manage.py runserver

Endpoints

Deployed to https://soundem-api.herokuapp.com

POST /api/v1/register

Request

{
  "email": "john@example.com",
  "password": "abc123"
}

Response

{
  "user": {
    "email": "john@example.com",
    "id": 1,
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MX0.G01VbljXYZa-Cfd-HveE4U0mHGFLrgo36M838S3K5RE"
  }
}

POST /api/v1/login

Request

{
  "email": "john@example.com",
  "password": "abc123"
}

Response

{
  "user": {
    "email": "john@example.com",
    "id": 1,
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MX0.G01VbljXYZa-Cfd-HveE4U0mHGFLrgo36M838S3K5RE"
  }
}

GET /api/v1/artists

Response

{
  "artists": [
    {
      "albums": [
        1
      ],
      "bio": "",
      "id": 1,
      "name": "Lana del Rey"
    },
    {
      "albums": [
        2
      ],
      "bio": "",
      "id": 2,
      "name": "AJ Davila"
    }
  ]
}

GET /api/v1/albums

Response

{
  "albums": [
    {
      "id": 1,
      "name": "Ultraviolence",
      "songs": [
        1,
        2,
        3
      ]
    },
    {
      "id": 2,
      "name": "Terror Amor",
      "songs": [
        4,
        5
      ]
    }
  ]
}

GET /api/v1/songs

Response

{
  "songs": [
    {
      "album": 1,
      "favorite": false,
      "id": 1,
      "name": "Pretty When You Cry"
    },
    {
      "album": 1,
      "favorite": false,
      "id": 2,
      "name": "Money Power Glory"
    },
    {
      "album": 1,
      "favorite": false,
      "id": 3,
      "name": "West Coast"
    },
    {
      "album": 2,
      "favorite": false,
      "id": 4,
      "name": "Animal"
    },
    {
      "album": 2,
      "favorite": false,
      "id": 5,
      "name": "Dura Como Piedra"
    }
  ]
}

PUT /api/v1/songs/:id/favorite

Response

{
  "song": {
    "album": 1,
    "favorite": true,
    "id": 1,
    "name": "Pretty When You Cry"
  }
}

About

RESTful API for demo application developed at BFTW

License:MIT License


Languages

Language:Python 100.0%