The FrequenC API is the main way of communication between the client and the server, and it's used for sending commands, and receiving events.
- FrequenC API
- Table of Contents
- Used abbreviations
- Development
- /version - Fetching the version
- /v1/info - Fetch information about the node
- /v1/decodetrack - Decoding track
- /v1/decodetracks - Bulk decoding tracks
- /v1/encodetrack - Encoding track
- /v1/encodetracks - Bulk encoding tracks
- /v1/loadtracks - Loading tracks
- /v1/sessions/Xe16/players/Xe18 - Update a player information
- /v1/websocket - The WebSocket
Important
This is a beta version of the API.
Note
All endpoints require authentication.
Warning
All endpoints, except /version
, are prefixed with /v1
and may change between versions.
Warning
We reserve the right of breaking changes without major version bumps if they are said to be necessary in this documentation.
This guide contains examples with strings that are random, but use a fixed length. Those are represented by Xe
+ a number, which is the length of the string.
When a string is not fixed, it will be represented by a random amount of X
characters, which MUST NOT be taken as a fixed length.
FrequenC uses a custom HTTP parser, which is stricter and faster than most HTTP parsers. Using its customizability, it has been implemented following limitations:
- Maximum headers amount: 10
There is no support for custom Content-Type
, and all responses should be pure text. However, there is support for chunked
Transfer-Encoding
, but should only be used when necessary.
Clients may want to support multiple versions of FrequenC, and to make that possible, it's required to create an unversioned endpoint which displays the node version.
- Purpose: Fetches the node version.
- Supported methods:
GET
- Required headers:
Authorization
- Response: The version of FrequenC.
- Response status:
200 OK
- Response type:
text/plain
Information about the FrequenC node may be useful for higher-level clients, which may want to disable sources or filters based on the node's capabilities.
- Purpose: Fetches information about the node.
- Supported methods:
GET
- Required headers:
Authorization
- Response: Node information JSON
- Response status:
200 OK
- Response type:
application/json
version
- Object: The version of the node.major
- Integer: The major version.minor
- Integer: The minor version.patch
- Integer: The patch version.
git
- Object: Information about the pre-built binary.branch
- String: The branch of the commit.commit
- String: The commit SHA-1 hash.
source_managers
- Array: The source managers supported by the node.filters
- Array: The filters supported by the node. Always empty in beta.
{
"version": {
"major": 1,
"minor": 0,
"patch": 0
},
"git": {
"branch": "main",
"commit": "XXXXXXXX"
},
"source_managers": [
"youtube",
...
],
"filters": [
"timescale",
"volume",
...
]
}
Decoding tracks is a core part of the FrequenC design, and it should be used whenever possible over the raw JSON track format.
Clients SHOULD implement local decoding of tracks, as it's faster and more efficient than using the /decodetrack
endpoint. However, clients MAY use the /decodetrack
endpoint as a fallback.
- Purpose: Decodes a track.
- Supported methods:
GET
- Required headers:
Authorization
- Query parameters:
encodedTrack
- Response: The track JSON or none.
- Response status:
200 OK
or400 Bad Request
- Response type:
application/json
or none.
A encoded track base64-encoded string.
XXXXXXXXXX...
encoded
- String: The encoded track.info
- Object: The track information.title
- String: The title of the track.author
- String: The author of the track.length
- Number: The length of the track.identifier
- String: The identifier of the track.is_stream
- Boolean: If the track is a stream.uri
- String: The URI of the track.artwork_url
- Nullable String: The artwork URL of the track.isrc
- Nullable String: The ISRC of the track.source_name
- String: The source name of the track.
{
"encoded": "XXXXXXXXXX...",
"info": {
"title": "Title",
"author": "Author",
"length": 1000,
"identifier": "Identifier",
"is_stream": false,
"uri": "https://example.com",
"artwork_url": "https://example.com",
"isrc": "ISRC",
"source_name": "Source"
}
}
Note
The encoded
key is the same as the encodedTrack
query parameter.
Warning
artworkUrl
and isrc
may be not be present in all tracks.
Decoding multiple tracks at once is a core part of the FrequenC design, and it should be used whenever possible over the raw JSON track format.
Clients SHOULD implement local decoding of tracks, as it's faster and more efficient than using the /decodetracks
endpoint. However, clients MAY use the /decodetracks
endpoint as a fallback.
- Purpose: Decodes multiple tracks.
- Supported methods:
POST
- Required headers:
Authorization
- Request body: An array of encoded tracks.
- Response: An array of track JSONs or none.
- Response status:
200 OK
or400 Bad Request
- Response type:
application/json
or none.
An array of encoded tracks base64-encoded strings.
[
"XXXXXXXXXX...",
"XXXXXXXXXX...",
...
]
encoded
- String: The encoded track.info
- Object: The track information.title
- String: The title of the track.author
- String: The author of the track.length
- Number: The length of the track.identifier
- String: The identifier of the track.is_stream
- Boolean: If the track is a stream.uri
- String: The URI of the track.artwork_url
- Nullable String: The artwork URL of the track.isrc
- Nullable String: The ISRC of the track.source_name
- String: The source name of the track.
[
{
"encoded": "XXXXXXXXXX...",
"info": {
"title": "Title",
"author": "Author",
"length": 1000,
"identifier": "Identifier",
"is_stream": false,
"uri": "https://example.com",
"artwork_url": "https://example.com",
"isrc": "ISRC",
"source_name": "Source"
}
},
{
"encoded": "XXXXXXXXXX...",
"info": {
"title": "Title",
"author": "Author",
"length": 1000,
"identifier": "Identifier",
"is_stream": false,
"uri": "https://example.com",
"artwork_url": "https://example.com",
"isrc": "ISRC",
"source_name": "Source"
}
},
...
]
Clients SHOULD implement local encoding of tracks, as it's faster and more efficient than using the /encodetrack
endpoint. However, clients MAY use the /encodetrack
endpoint as a fallback.
- Purpose: Encodes a track.
- Supported methods:
POST
- Required headers:
Authorization
- Request body: The encoded track.
- Response: The encoded track or none.
- Response status:
200 OK
or400 Bad Request
- Response type:
application/json
or none.
title
- String: The title of the track.author
- String: The author of the track.length
- Number: The length of the track.identifier
- String: The identifier of the track.is_stream
- Boolean: If the track is a stream.uri
- String: The URI of the track.artwork_url
- Nullable String: The artwork URL of the track.isrc
- Nullable String: The ISRC of the track.source_name
- String: The source name of the track.
A encoded track base64-encoded string.
XXXXXXXXXX...
Clients SHOULD implement local encoding of tracks, as it's faster and more efficient than using the /encodetracks
endpoint. However, clients MAY use the /encodetracks
endpoint as a fallback.
- Purpose: Encodes multiple tracks.
- Supported methods:
POST
- Required headers:
Authorization
- Request body: An array of tracks.
- Response: An array of encoded tracks or none.
- Response status:
200 OK
or400 Bad Request
- Response type:
application/json
or none.
title
- String: The title of the track.author
- String: The author of the track.length
- Number: The length of the track.identifier
- String: The identifier of the track.is_stream
- Boolean: If the track is a stream.uri
- String: The URI of the track.artwork_url
- Nullable String: The artwork URL of the track.isrc
- Nullable String: The ISRC of the track.source_name
- String: The source name of the track.
[
{
"title": "Title",
"author": "Author",
"length": 1000,
"identifier": "Identifier",
"is_stream": false,
"uri": "https://example.com",
"artwork_url": "https://example.com",
"isrc": "ISRC",
"source_name": "Source"
},
{
"title": "Title",
"author": "Author",
"length": 1000,
"identifier": "Identifier",
"is_stream": false,
"uri": "https://example.com",
"artwork_url": "https://example.com",
"isrc": "ISRC",
"source_name": "Source"
},
...
]
A encoded track base64-encoded string.
[
"XXXXXXXXXX...",
"XXXXXXXXXX...",
...
]
Loading tracks is the most important part of the FrequenC API, and it's used for loading tracks from different sources. It searches the track query in the appropriate source and generates a list of tracks.
- Purpose: Loads tracks from a source.
- Supported methods:
GET
- Required headers:
Authorization
- Query parameters:
identifier
- Response: The load type and data.
- Response status:
200 OK
- Response type:
application/json
prefix
- Non-existable String: The source prefix.query
- String: The query.
Note
The prefix
is not required, and it's only used for identifying the source when performing a search. Currently, only YouTube (ytsearch:
) is supported.
ytsearch:example
loadType
- String: The load type.data
- Non-existable Array, Object or String: The track information.
{
"loadType": "search",
"data": [
{ Track Info },
{ Track Info },
...
]
}
{
"loadType": "empty"
}
{
"loadType": "error",
"data": "Error message"
}
This endpoint allows clients to update information about the player, allowing FrequenC to connect to the Discord voice servers, update player state and etc.
- Purpose: Updates player information.
- Supported methods:
GET
,PATCH
andDELETE
- Required headers:
Authorization
- Request body: The player information.
- Response: None.
- Response status:
204 No Content
- Response type: None.
voice
- Non-existable Object: The voice information.endpoint
- String: The Discord voice server endpoint.session_id
- String: The Discord voice server session ID.token
- String: The Discord voice server token.
track
- String: The encoded track of the current playing track.
{
"voice": {
"endpoint": "brazil1001.discord.media",
"session_id": "Xe32",
"token": "Xe16"
},
"track": "XXXXXXXXXX..."
}
voice
- Non-existable Object: The voice information.endpoint
- String: The Discord voice server endpoint.session_id
- String: The Discord voice server session ID.token
- String: The Discord voice server token.
track
- String: The encoded track of the current playing track.
Warning
The endpoint
, session_id
and token
are Discord voice server specific, and should not be shared with anyone. However they're only temporarily confidential.
{
"voice": {
"endpoint": "brazil1001.discord.media",
"session_id": "Xe32",
"token": "Xe16"
},
"track: "XXXXXXXXXX..."
}
Returns a 204 No Content
response.
The websocket is the main way of communication between the client and FrequenC. It's used for receiving numerous events of the node and players.
- Purpose: Connects to the WebSocket.
- Supported methods:
GET
- Required headers:
Authorization
,User-Id
andClient-Info
(NAME/VERSION (BOT NAME)
) - Response: None.
Note
Resuming support is expected, but not confirmed.
FrequenC uses events sent in JSON encoding, allowing clients to easily understand by using a JSON parser.
op
- String: The event op.
op
- String: The event op. (ready)resumed
- Boolean: If the session was resumed. Clients SHOULD NOT parse this as of beta.session_id
- String: The session ID.
{
"op": "ready",
"resumed": false,
"session_id": "Xe16"
}