-
Clone the repo
git clone https://github.com/amit-ksh/video-api.git
-
cd video-api
-
Copy
.env.example
file, rename to.env
-
Build and run the server:
docker compose up
-
Run database migrations
docker compose exec api flask db upgrade -OR- scripts\migrate.sh
-
Server Running At:
http://localhost:5000/
(openhttp://localhost:5000/videos
)
docker compose exec api python -m pytest
-OR-
scripts\test.sh
-
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 }
-
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>" }
-
Get All Videos
Request
curl --location 'http://127.0.0.1:5000/videos'
Response
{ "videos": [ { "title": "Video", "description": "video description", "status": "ACTIVE" } ] }
-
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" }
-
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" } ] }
-
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" }
-
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" }
-
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" }