2023-10-28 12:51:20 +00:00
# cobalt api documentation
this document provides info about methods and acceptable variables for all cobalt api requests.
2023-06-05 06:43:04 +00:00
```
2024-05-22 01:54:38 +00:00
👍 you can use api.cobalt.tools in your projects for free, just don't be an asshole.
2023-10-28 12:51:20 +00:00
```
## POST: `/api/json`
cobalt's main processing endpoint.
request body type: `application/json`
response body type: `application/json`
2023-06-05 06:43:04 +00:00
```
2023-10-28 12:51:20 +00:00
⚠️ you must include Accept and Content-Type headers with every POST /api/json request.
2023-06-05 06:43:04 +00:00
2023-10-28 12:51:20 +00:00
Accept: application/json
Content-Type: application/json
```
2022-11-12 16:40:11 +00:00
2023-10-28 12:51:20 +00:00
### request body variables
2024-01-17 14:30:22 +00:00
| key | type | variables | default | description |
|:------------------|:----------|:-----------------------------------|:----------|:--------------------------------------------------------------------------------|
| `url` | `string` | URL encoded as URI | `null` | **must** be included in every request. |
| `vCodec` | `string` | `h264 / av1 / vp9` | `h264` | applies only to youtube downloads. `h264` is recommended for phones. |
| `vQuality` | `string` | `144 / ... / 2160 / max` | `720` | `720` quality is recommended for phones. |
| `aFormat` | `string` | `best / mp3 / ogg / wav / opus` | `mp3` | |
| `filenamePattern` | `string` | `classic / pretty / basic / nerdy` | `classic` | changes the way files are named. previews can be seen in the web app. |
| `isAudioOnly` | `boolean` | `true / false` | `false` | |
| `isTTFullAudio` | `boolean` | `true / false` | `false` | enables download of original sound used in a tiktok video. |
| `isAudioMuted` | `boolean` | `true / false` | `false` | disables audio track in video downloads. |
2024-01-02 06:49:20 +00:00
| `dubLang` | `boolean` | `true / false` | `false` | backend uses Accept-Language header for youtube video audio tracks when `true` . |
2024-01-17 14:30:22 +00:00
| `disableMetadata` | `boolean` | `true / false` | `false` | disables file metadata when set to `true` . |
| `twitterGif` | `boolean` | `true / false` | `false` | changes whether twitter gifs are converted to .gif |
2024-04-29 18:27:17 +00:00
| `tiktokH265` | `boolean` | `true / false` | `false` | changes whether 1080p h265 videos are preferred or not. |
2022-11-12 16:40:11 +00:00
2023-10-28 12:51:20 +00:00
### response body variables
| key | type | variables |
|:-------------|:---------|:------------------------------------------------------------|
| `status` | `string` | `error / redirect / stream / success / rate-limit / picker` |
| `text` | `string` | various text, mostly used for errors |
| `url` | `string` | direct link to a file or a link to cobalt's live render |
| `pickerType` | `string` | `various / images` |
| `picker` | `array` | array of picker items |
| `audio` | `string` | direct link to a file or a link to cobalt's live render |
2022-11-12 16:40:11 +00:00
2023-10-28 12:51:20 +00:00
### picker item variables
item type: `object`
2022-11-12 16:40:11 +00:00
2023-10-28 12:51:20 +00:00
| key | type | variables | description |
|:--------|:---------|:--------------------------------------------------------|:---------------------------------------|
2024-07-26 16:02:59 +00:00
| `type` | `string` | `video / photo / gif` | used only if `pickerType` is `various` |
2023-10-28 12:51:20 +00:00
| `url` | `string` | direct link to a file or a link to cobalt's live render | |
2024-07-26 16:02:59 +00:00
| `thumb` | `string` | item thumbnail that's displayed in the picker | used for `video` and `gif` types |
2022-11-12 16:40:11 +00:00
2023-10-28 12:51:20 +00:00
## GET: `/api/stream`
2024-03-06 17:09:19 +00:00
cobalt's live render (or stream) endpoint. usually, you will receive a url to this endpoint
from a successful call to `/api/json` . however, the parameters passed to it are **opaque**
and **unmodifiable** from your (the api client's) perspective, and can change between versions.
2022-11-12 16:40:11 +00:00
2024-03-06 17:09:19 +00:00
therefore you don't need to worry about what they mean - but if you really want to know, you can
2024-04-19 04:00:47 +00:00
[read the source code ](/src/modules/stream/manage.js ).
2023-06-07 15:41:06 +00:00
2023-10-28 12:51:20 +00:00
## GET: `/api/serverInfo`
returns current basic server info.
response body type: `application/json`
2023-06-07 15:41:06 +00:00
2023-10-28 12:51:20 +00:00
### response body variables
| key | type | variables |
|:------------|:---------|:------------------|
| `version` | `string` | cobalt version |
| `commit` | `string` | git commit |
| `branch` | `string` | git branch |
| `name` | `string` | server name |
| `url` | `string` | server url |
2024-07-07 13:31:55 +00:00
| `cors` | `number` | cors status |
2023-10-28 12:51:20 +00:00
| `startTime` | `string` | server start time |