tubearchivist-frontend/tubearchivist/api
2022-04-01 16:24:40 +07:00
..
migrations new django api app, implementing basic get views 2022-01-10 22:51:52 +07:00
src clean up prints 2022-03-29 17:03:34 +07:00
__init__.py new django api app, implementing basic get views 2022-01-10 22:51:52 +07:00
admin.py new django api app, implementing basic get views 2022-01-10 22:51:52 +07:00
apps.py new django api app, implementing basic get views 2022-01-10 22:51:52 +07:00
models.py implement api token auth 2022-01-11 14:15:36 +07:00
README.md return better data for ping api, add to readme 2022-04-01 16:24:40 +07:00
serializers.py new django api app, implementing basic get views 2022-01-10 22:51:52 +07:00
tests.py new django api app, implementing basic get views 2022-01-10 22:51:52 +07:00
urls.py add connection test api view 2022-03-31 21:13:21 +07:00
views.py return better data for ping api, add to readme 2022-04-01 16:24:40 +07:00

TubeArchivist API

Documentation of available API endpoints.
Note: This is very early alpha and will change!

Authentication

API token will get automatically created, accessible on the settings page. Token needs to be passed as an authorization header with every request. Additionally session based authentication is enabled too: When you are logged into your TubeArchivist instance, you'll have access to the api in the browser for testing.

Curl example:

curl -v /api/video/<video-id>/ \
    -H "Authorization: Token xxxxxxxxxx"

Python requests example:

import requests

url = "/api/video/<video-id>/"
headers = {"Authorization": "Token xxxxxxxxxx"}
response = requests.get(url, headers=headers)

Login View

Return token and user ID for username and password:
POST /api/login

{
    "username": "tubearchivist",
    "password": "verysecret"
}

after successful login returns

{
    "token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "user_id": 1
}

Video List View

/api/video/

Video Item View

/api/video/<video_id>/

Video Progress View

/api/video/<video_id>/progress

Progress is stored for each user.

Get last player position of a video

GET /api/video/<video_id>/progress

{
    "youtube_id": "<video_id>",
    "user_id": 1,
    "position": 100
}

Post player position of video

POST /api/video/<video_id>/progress

{
    "position": 100
}

Delete player position of video

DELETE /api/video/<video_id>/progress

Channel List View

/api/channel/

Subscribe to a list of channels

POST /api/channel/

{
    "data": [
        {"channel_id": "UC9-y-6csu5WGm29I7JiwpnA", "channel_subscribed": true}
    ]
}

Channel Item View

/api/channel/<channel_id>/

Playlists Item View

/api/playlist/<playlist_id>/

Download Queue List View

/api/download/

Add list of videos to download queue

POST /api/download/

{
    "data": [
        {"youtube_id": "NYj3DnI81AQ", "status": "pending"}
    ]
}

Download Queue Item View

/api/download/<video_id>/

Ping View

Validate your connection with the API
GET /api/ping

When valid returns message with user id:

{
    "response": "pong",
    "user": 1
}