Developer API
API keys for members and a JSON API for apps and other websites - videos, channels, comments, likes, sign-in and imports - with limits, approval and a log.
The Developer API plugin opens your site to apps and other websites. Members make their own API keys; a phone app, a website or a script uses a key to read your videos and channels, to sign members in and to act for them - comment, like, subscribe, bring a video in by its link. Everything answers JSON.
Switching it on
The plugin is free and works with every licence. Switch it on at Admin → Plugins (the card says Developer API).
Its pages are Developer API, API keys and API log under Plugins in the admin menu
(admin/plugin.php?code=developer-api). Members find their keys under Settings → API keys; the guide for developers
is at /developers.
Your site's own api.php - the one its pages talk to - does not change. A call without a key never reaches the plugin.
Keys for members
Under Settings → API keys a member gives a key a name ("My Android app"), ticks what it may do and, if the key will be used from a web page, lists the sites that may use it from a browser.
| Scope | What a key with it may do |
|---|---|
| Read | Public videos, channels, categories, Shorts, playlists and comments. |
| Account | Register and sign members in, read the signed-in member's own videos, playlists and subscriptions. |
| Write | Comment, like and subscribe as the signed-in member. |
| Upload | Bring a video in by its link (an import) as the signed-in member. |
A key starts with avk_. It stays hidden on the page; Show puts it in, Hide takes it out, Copy puts it on the
clipboard - as often as needed. New secret makes a new key and stops the old one at once. The site keeps a hash of the
key and a copy sealed with the site's own secret (AES-256-GCM), never the key in plain text.
A key used alone acts for the member who owns it. An app that signs other members in gets a token for each of them
(avt_…) and sends it as Authorization: Bearer … next to the key; the call then acts for that member.
The settings
| Setting | What it does |
|---|---|
| The API is on | Off, every call is answered "switched off"; keys are kept. |
| Who may have keys | Everyone · members with a confirmed e-mail · members whose package has "May have API keys" · everyone, but each new key waits for your approval · only the people who run the site. Admins and moderators always may. |
| Keys a member may have | How many keys one member may have. |
| Calls a minute, per key / Calls a day, per key | The limits of every key, unless you give a key its own under API keys. Answers carry X-RateLimit-Limit and X-RateLimit-Remaining. |
| What keys may be allowed to do | Untick a scope to keep it from everyone. |
| Anybody may read public things without a key | Read routes answer without a key; Calls a minute from one address without a key limits them. |
| Apps may sign members in (auth/login) / Apps may make new accounts (auth/register) | A member signed in through an app stays signed in for so many days. |
| Hand apps the video files they may play | One video lists the files the member may play, as addresses that work for so many hours. |
| Imports a member may make through the API in an hour | Per member. |
| Keep a log of the calls | Every call, kept so many days. |
API keys and the log
API keys lists every key of every member: the member, what it may do, its calls today and in all, when and from where it was last used, and its state. Approve a key that waits, Block a key (its calls are refused, the member sees it as blocked), give it its own limits and scopes, or Delete it.
API log shows the latest calls - when, which key, which member, the call, the answer, how long it took and where it came from. Tick Refused calls only to see what went wrong. A cron job removes old lines and old tokens.
For developers
The guide at /developers has the address (https://your-site/developer-api/{route}), the answer format
({"ok": true, "data": …, "meta": …} or {"ok": false, "error": {"code", "message"}} with an HTTP status that fits), every
route, and samples in curl, JavaScript and PHP. The routes cover videos (latest, trending, popular, search, by channel,
category or tag), one video with its files, related videos, comments (read and write), likes, channels with their videos
and playlists, subscribe, categories, Shorts, playlists, the member's own videos, playlists and subscriptions, imports,
and auth/register, auth/login (with the two-step code), auth/me and auth/logout.
Honest limits
- A key used in a web page can be read by anybody who opens that page. Give such a key the Read scope only and list your site under its allowed sites; a browser on another site is then refused. Programs (not browsers) send no Origin, so the allowed-sites list cannot stop a copied key used from a server - New secret does.
- Uploading a video file through the API is not offered; a video comes in by its link (an import), as the Upload scope says.
- The secret that seals the keys is stored with the site's settings. Restoring a database without it leaves the stored keys unreadable; members then make new keys.