amit-ksh / video-api

Repository from Github https://github.comamit-ksh/video-apiRepository from Github https://github.comamit-ksh/video-api

Video API

Development Setup

  1. Clone the repo git clone https://github.com/amit-ksh/video-api.git

  2. cd video-api

  3. Copy .env.example file, rename to .env

  4. Build and run the server: docker compose up

  5. Run database migrations

    docker compose exec api flask db upgrade
    -OR-
    scripts\migrate.sh
  6. Server Running At: http://localhost:5000/ (open http://localhost:5000/videos)

How to run tests

docker compose exec api python -m pytest
-OR-
scripts\test.sh

API

User

  1. User Registration

    Request

    curl --location 'http://127.0.0.1:5000/user/register' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "email": "john@mail.com",
        "password": "password"
    }'

    Response

    {
        "created_at": "2024-05-06T12:25:08.840470",
        "email": "john@mail.com",
        "id": 1
    }
  2. User Login

    Request

    curl --location 'http://127.0.0.1:5000/user/login' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "email": "john@mail.com",
        "password": "password"
    }'

    Response

    {
        "access_token": "<TOKEN>"
    }

Video

  1. Get All Videos

    Request

    curl --location 'http://127.0.0.1:5000/videos'

    Response

    {
        "videos": [
            {
                "title": "Video",
                "description": "video description",
                "status": "ACTIVE"
            }
        ]
    }
  2. Get Video by ID

    Request

    curl --location 'http://127.0.0.1:5000/video/1'

    Response

    {
        "created_at": "2024-05-06T12:28:43.180936",
        "description": "video description",
        "id": 1,
        "status": "active",
        "title": "Brand new video"
    }
  3. Get Videos By Status

    Request

    curl --location 'http://127.0.0.1:5000/videos/archived'

    Response

    {
        "archived": [
            {
                "created_at": "2024-05-06T12:30:39.934096",
                "description": "video description",
                "id": 2,
                "status": "archived",
                "title": "Brand new video"
            }
        ]
    }
  4. Create Video

    Request

    curl --location 'http://127.0.0.1:5000/video' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <TOKEN>' \
    --data '{
        "title": "Brand new video",
        "description": "video description"
    }'

    Response

    {
        "created_at": "2024-05-06T12:28:43.180936",
        "description": "video description",
        "id": 1,
        "status": "active",
        "title": "Brand new video"
    }
  5. Get Update Video By ID

    Request

    curl --location --request PUT 'http://127.0.0.1:5000/video/1' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <TOKEN>' \
    --data '{
        "title": "Updated Video",
        "description": "updated video description",
        "status": "ARCHIVED"
    }'

    Response

    {
        "title": "Updated Video",
        "description": "updated video description",
        "status": "ARCHIVED"
    }
  6. Delete Video

    Request

    curl --location --request DELETE 'http://127.0.0.1:5000/video/3' \
    --header 'Authorization: Bearer <TOKEN>'

    Response

    {
        "title": "Video",
        "description": "video description",
        "status": "ARCHIVED"
    }

About


Languages

Language:Python 96.4%Language:Mako 2.2%Language:Dockerfile 0.7%Language:Shell 0.6%