Developers

REST API

Everything here describes itself: send OPTIONS to a route for its arguments and schema. The tables below come from the same registration code.

The track on media is public and keeps its shape within a major version. The riff/v1 routes are the player's own, there for the player and the Listen block to call, and may change in any release.

The track on media

Every audio and video item in wp/v2/media carries riff_track: The file as a track the player reads; null for files that are not audio or video. It is read only, and null for any other file. Its shape is the track schema.

GET /wp-json/wp/v2/media/123?_fields=id,riff_track

Routes

GET /riff/v1/library

riff-library

Arguments

NameTypeDescription
pageintegerPage of the library. Default 1.

Response

PropertyTypeDescription
itemsarray
items[].idintegerPost ID.
items[].titlestringPost title.
items[].urlstringPermalink.
items[].artiststringThe artist every track shares, or empty.
items[].artarrayArtwork, smallest first.
items[].art[].srcstring
items[].art[].sizesstring
items[].countintegerNumber of tracks.
items[].metastringA one-line byline for the post, written by a feature that knows how to say it in the language.
items[].durationnumberTotal length in seconds, 0 when unknown.
pageinteger
pagesinteger
totalinteger

GET /riff/v1/library/{id}

riff-library-post

Arguments

NameTypeDescription
idinteger RequiredPost ID.

Response

PropertyTypeDescription
idintegerPost ID.
titlestringPost title.
urlstringPermalink.
artiststringThe artist every track shares, or empty.
artarrayArtwork, smallest first.
art[].srcstring
art[].sizesstring
countintegerNumber of tracks.
metastringA one-line byline for the post, written by a feature that knows how to say it in the language.
durationnumberTotal length in seconds, 0 when unknown.
tracksarrayThe tracks, in order, as the player reads them.
htmlstringThe media blocks rendered as the post renders them.

GET /riff/v1/tracks

Tracks from the Media Library, by title, or one album in its order, or one artist; searchable by title, artist and album. A visitor sees every track except those uploaded to an unpublished or password-protected post; someone who can upload files sees them all.

Arguments

NameTypeDescription
searchstringWords to look for, at least two characters: a track matches on its title, artist or album; an album or artist on its name. Default "".
albumintegerOnly the tracks on this album, by term ID, in album order. Default 0.
artistintegerOnly the tracks by this artist, by term ID. Default 0.
includearrayOnly these, by ID; what the requester cannot see is still left out. Default [].
orderbystringBy title, the most recently added first, in the order include names them, or shuffled by seed. An album is in album order unless shuffled. Default "title".
seedintegerWith orderby random, the shuffle: the same seed deals the same order, so its pages follow on without a track twice. Default 0.
pageintegerPage of results. Default 1.
afterstringWhere the last page ended, as its next said: the page after it, which stays fast however deep into the library it is. By title or newest first, and not with album or include. Default "".
per_pageintegerTracks per page. Default 50.

Response

PropertyTypeDescription
itemsarrayTracks, in the shape of the track schema.
items[].idstringThe attachment ID, or "url:" and a hash for a file outside the Media Library.
items[].srcstring
items[].typestring One of audio, video.
items[].titlestring
items[].artiststring
items[].albumstring
items[].yearintegerThe year from the file's tags, or 0.
items[].discintegerWhich disc of a set the track is on, from the file's disc number tag (1 for "1/2"), or 0 when the tags do not say.
items[].durationnumberSeconds, 0 when unknown.
items[].langstringThe language of the title and artist, as a lang attribute takes it, from the file's tags; empty when the file does not say.
items[].formatstringThe container, lower case, as WordPress read it from the file: mp3, flac, m4a. Empty when unknown.
items[].bitrateintegerKilobits per second, 0 when unknown.
items[].losslessbooleanWhether the encoding is lossless.
items[].bitsintegerBits per sample, as WordPress read it from the file; 0 when the format does not say, as MP3 does not.
items[].rateintegerSamples per second, 0 when unknown.
items[].levelsstringThe track's loudness over time as digits 0 to 9, one per sample, when something has measured it; the drawn cover puts it in the groove. Empty otherwise.
items[].artarrayArtwork, smallest first.
items[].art[].srcstring
items[].art[].sizesstring
items[].art[].altstringWhat the picture shows, for a screen reader: the image's alt text, or the album and artist a drawn cover names.
items[].captionsarrayText tracks for a video: the WebVTT file its Captions field names, or the tracks its video block carries.
items[].captions[].srcstring
items[].captions[].labelstring
items[].captions[].srclangstring
items[].captions[].kindstring One of captions, subtitles, descriptions.
items[].videoobject | null
items[].video.srcstring
items[].video.posterstring
items[].video.captionsarray
items[].video.captions[].srcstring
items[].video.captions[].labelstring
items[].video.captions[].srclangstring
items[].video.captions[].kindstring One of captions, subtitles, descriptions.
items[].postobject | null
items[].post.idinteger
items[].post.titlestring
items[].post.urlstring
items[].lockedbooleanWhether the current visitor may not play the track, as riff_can_play decided. A locked track has no src.
items[].unlockstringWhere a locked track sends the visitor to unlock it, from riff_unlock_url. Empty otherwise.
pageinteger
pagesinteger
totalinteger
nextstringWhere this page ended, to pass as after for the next; empty when this is the last, or for an album or include.

GET /riff/v1/albums

Albums with at least one track the requester can see, by name, each with its artist, artwork and track count.

Arguments

NameTypeDescription
searchstringWords to look for, at least two characters: a track matches on its title, artist or album; an album or artist on its name. Default "".
artistintegerOnly the albums with a track by this artist, by term ID. Default 0.
includearrayOnly these, by ID; what the requester cannot see is still left out. Default [].
orderbystringBy name, or the most recently added first. Default "name".
pageintegerPage of results. Default 1.

Response

PropertyTypeDescription
itemsarray
items[].idintegerTerm ID.
items[].namestring
items[].countintegerTracks the requester can see.
items[].artiststringThe album's artist, or empty.
items[].artarrayThe album's first track's artwork as the player shows it, as { src, sizes }.
pageinteger
pagesinteger
totalinteger

GET /riff/v1/artists

Artists with at least one track the requester can see, by name, each with a track count.

Arguments

NameTypeDescription
searchstringWords to look for, at least two characters: a track matches on its title, artist or album; an album or artist on its name. Default "".
includearrayOnly these, by ID; what the requester cannot see is still left out. Default [].
pageintegerPage of results. Default 1.

Response

PropertyTypeDescription
itemsarray
items[].idintegerTerm ID.
items[].namestring
items[].countintegerTracks the requester can see.
pageinteger
pagesinteger
totalinteger

GET, POST /riff/v1/users/{user}/likes

The signed-in user's likes, newest first. Kept as the riff_likes user option, one list per site.

Arguments

NameTypeDescription
userstringWhose: me for the signed-in user, or a user ID, for someone who may edit that user.
itemsarray RequiredLikes to add: a kind and an ID each, and when it was liked.

Response

PropertyTypeDescription
itemsarray
items[].kindstring One of track, album, artist.
items[].idinteger
items[].atintegerWhen it was liked, in milliseconds since the epoch.

DELETE /riff/v1/users/{user}/likes/{kind}/{id}

The signed-in user's likes, newest first. Kept as the riff_likes user option, one list per site.

Arguments

NameTypeDescription
userstringWhose: me for the signed-in user, or a user ID, for someone who may edit that user.
kindstringWhat was liked: track, album or artist.
idintegerIts ID.

Response

PropertyTypeDescription
itemsarray
items[].kindstring One of track, album, artist.
items[].idinteger
items[].atintegerWhen it was liked, in milliseconds since the epoch.

GET, POST, DELETE /riff/v1/users/{user}/history

The tracks the signed-in user played, newest first, at most 30. Kept as the riff_history user option, one list per site.

Arguments

NameTypeDescription
userstringWhose: me for the signed-in user, or a user ID, for someone who may edit that user.
itemsarray RequiredPlays to add: a track's ID each, and when it was played.

Response

PropertyTypeDescription
itemsarray
items[].idstringThe attachment ID, or "url:" and a hash for a file outside the Media Library.
items[].srcstring
items[].typestring One of audio, video.
items[].titlestring
items[].artiststring
items[].albumstring
items[].yearintegerThe year from the file's tags, or 0.
items[].discintegerWhich disc of a set the track is on, from the file's disc number tag (1 for "1/2"), or 0 when the tags do not say.
items[].durationnumberSeconds, 0 when unknown.
items[].langstringThe language of the title and artist, as a lang attribute takes it, from the file's tags; empty when the file does not say.
items[].formatstringThe container, lower case, as WordPress read it from the file: mp3, flac, m4a. Empty when unknown.
items[].bitrateintegerKilobits per second, 0 when unknown.
items[].losslessbooleanWhether the encoding is lossless.
items[].bitsintegerBits per sample, as WordPress read it from the file; 0 when the format does not say, as MP3 does not.
items[].rateintegerSamples per second, 0 when unknown.
items[].levelsstringThe track's loudness over time as digits 0 to 9, one per sample, when something has measured it; the drawn cover puts it in the groove. Empty otherwise.
items[].artarrayArtwork, smallest first.
items[].art[].srcstring
items[].art[].sizesstring
items[].art[].altstringWhat the picture shows, for a screen reader: the image's alt text, or the album and artist a drawn cover names.
items[].captionsarrayText tracks for a video: the WebVTT file its Captions field names, or the tracks its video block carries.
items[].captions[].srcstring
items[].captions[].labelstring
items[].captions[].srclangstring
items[].captions[].kindstring One of captions, subtitles, descriptions.
items[].videoobject | null
items[].video.srcstring
items[].video.posterstring
items[].video.captionsarray
items[].video.captions[].srcstring
items[].video.captions[].labelstring
items[].video.captions[].srclangstring
items[].video.captions[].kindstring One of captions, subtitles, descriptions.
items[].postobject | null
items[].post.idinteger
items[].post.titlestring
items[].post.urlstring
items[].lockedbooleanWhether the current visitor may not play the track, as riff_can_play decided. A locked track has no src.
items[].unlockstringWhere a locked track sends the visitor to unlock it, from riff_unlock_url. Empty otherwise.
items[].playedintegerWhen it was played, in milliseconds since the epoch.

GET, POST /riff/v1/users/{user}/playlists

A user's playlists, the most recently changed first. Each is a private riff_playlist post holding a core Playlist block.

Arguments

NameTypeDescription
userstringWhose: me for the signed-in user, or a user ID, for someone who may edit that user.
titlestring RequiredThe playlist's name.
tracksarrayTracks, by their audio attachments' IDs, in order.

Response

PropertyTypeDescription
itemsarray
items[].idinteger
items[].titlestring
items[].countintegerHow many tracks it holds.
items[].coversarrayUp to four covers from its first tracks, for a mosaic.
items[].modifiedstringWhen it last changed.

GET, POST, DELETE /riff/v1/users/{user}/playlists/{id}

riff-playlist

Arguments

NameTypeDescription
userstringWhose: me for the signed-in user, or a user ID, for someone who may edit that user.
idintegerThe playlist's post ID.
titlestringThe playlist's name.
tracksarrayTracks, by their audio attachments' IDs, in order.

Response

PropertyTypeDescription
idinteger
titlestring
countintegerHow many tracks it holds.
coversarrayUp to four covers from its first tracks, for a mosaic.
modifiedstringWhen it last changed.
idsarrayEvery track's ID, in order, including any the requester cannot see.
tracksarrayThe tracks the requester can see, in the track shape, in order.
tracks[].idstringThe attachment ID, or "url:" and a hash for a file outside the Media Library.
tracks[].srcstring
tracks[].typestring One of audio, video.
tracks[].titlestring
tracks[].artiststring
tracks[].albumstring
tracks[].yearintegerThe year from the file's tags, or 0.
tracks[].discintegerWhich disc of a set the track is on, from the file's disc number tag (1 for "1/2"), or 0 when the tags do not say.
tracks[].durationnumberSeconds, 0 when unknown.
tracks[].langstringThe language of the title and artist, as a lang attribute takes it, from the file's tags; empty when the file does not say.
tracks[].formatstringThe container, lower case, as WordPress read it from the file: mp3, flac, m4a. Empty when unknown.
tracks[].bitrateintegerKilobits per second, 0 when unknown.
tracks[].losslessbooleanWhether the encoding is lossless.
tracks[].bitsintegerBits per sample, as WordPress read it from the file; 0 when the format does not say, as MP3 does not.
tracks[].rateintegerSamples per second, 0 when unknown.
tracks[].levelsstringThe track's loudness over time as digits 0 to 9, one per sample, when something has measured it; the drawn cover puts it in the groove. Empty otherwise.
tracks[].artarrayArtwork, smallest first.
tracks[].art[].srcstring
tracks[].art[].sizesstring
tracks[].art[].altstringWhat the picture shows, for a screen reader: the image's alt text, or the album and artist a drawn cover names.
tracks[].captionsarrayText tracks for a video: the WebVTT file its Captions field names, or the tracks its video block carries.
tracks[].captions[].srcstring
tracks[].captions[].labelstring
tracks[].captions[].srclangstring
tracks[].captions[].kindstring One of captions, subtitles, descriptions.
tracks[].videoobject | null
tracks[].video.srcstring
tracks[].video.posterstring
tracks[].video.captionsarray
tracks[].video.captions[].srcstring
tracks[].video.captions[].labelstring
tracks[].video.captions[].srclangstring
tracks[].video.captions[].kindstring One of captions, subtitles, descriptions.
tracks[].postobject | null
tracks[].post.idinteger
tracks[].post.titlestring
tracks[].post.urlstring
tracks[].lockedbooleanWhether the current visitor may not play the track, as riff_can_play decided. A locked track has no src.
tracks[].unlockstringWhere a locked track sends the visitor to unlock it, from riff_unlock_url. Empty otherwise.
tracks[].indexintegerThe track's place in the playlist, from 0.

POST /riff/v1/users/{user}/playlists/{id}/tracks

riff-playlist

Arguments

NameTypeDescription
userstringWhose: me for the signed-in user, or a user ID, for someone who may edit that user.
idintegerThe playlist's post ID.
tracksarray RequiredTracks, by their audio attachments' IDs, in order.

Response

PropertyTypeDescription
idinteger
titlestring
countintegerHow many tracks it holds.
coversarrayUp to four covers from its first tracks, for a mosaic.
modifiedstringWhen it last changed.
idsarrayEvery track's ID, in order, including any the requester cannot see.
tracksarrayThe tracks the requester can see, in the track shape, in order.
tracks[].idstringThe attachment ID, or "url:" and a hash for a file outside the Media Library.
tracks[].srcstring
tracks[].typestring One of audio, video.
tracks[].titlestring
tracks[].artiststring
tracks[].albumstring
tracks[].yearintegerThe year from the file's tags, or 0.
tracks[].discintegerWhich disc of a set the track is on, from the file's disc number tag (1 for "1/2"), or 0 when the tags do not say.
tracks[].durationnumberSeconds, 0 when unknown.
tracks[].langstringThe language of the title and artist, as a lang attribute takes it, from the file's tags; empty when the file does not say.
tracks[].formatstringThe container, lower case, as WordPress read it from the file: mp3, flac, m4a. Empty when unknown.
tracks[].bitrateintegerKilobits per second, 0 when unknown.
tracks[].losslessbooleanWhether the encoding is lossless.
tracks[].bitsintegerBits per sample, as WordPress read it from the file; 0 when the format does not say, as MP3 does not.
tracks[].rateintegerSamples per second, 0 when unknown.
tracks[].levelsstringThe track's loudness over time as digits 0 to 9, one per sample, when something has measured it; the drawn cover puts it in the groove. Empty otherwise.
tracks[].artarrayArtwork, smallest first.
tracks[].art[].srcstring
tracks[].art[].sizesstring
tracks[].art[].altstringWhat the picture shows, for a screen reader: the image's alt text, or the album and artist a drawn cover names.
tracks[].captionsarrayText tracks for a video: the WebVTT file its Captions field names, or the tracks its video block carries.
tracks[].captions[].srcstring
tracks[].captions[].labelstring
tracks[].captions[].srclangstring
tracks[].captions[].kindstring One of captions, subtitles, descriptions.
tracks[].videoobject | null
tracks[].video.srcstring
tracks[].video.posterstring
tracks[].video.captionsarray
tracks[].video.captions[].srcstring
tracks[].video.captions[].labelstring
tracks[].video.captions[].srclangstring
tracks[].video.captions[].kindstring One of captions, subtitles, descriptions.
tracks[].postobject | null
tracks[].post.idinteger
tracks[].post.titlestring
tracks[].post.urlstring
tracks[].lockedbooleanWhether the current visitor may not play the track, as riff_can_play decided. A locked track has no src.
tracks[].unlockstringWhere a locked track sends the visitor to unlock it, from riff_unlock_url. Empty otherwise.
tracks[].indexintegerThe track's place in the playlist, from 0.

DELETE /riff/v1/users/{user}/playlists/{id}/tracks/{index}

riff-playlist

Arguments

NameTypeDescription
userstringWhose: me for the signed-in user, or a user ID, for someone who may edit that user.
idintegerThe playlist's post ID.
indexintegerThe track's place in the playlist, from 0.

Response

PropertyTypeDescription
idinteger
titlestring
countintegerHow many tracks it holds.
coversarrayUp to four covers from its first tracks, for a mosaic.
modifiedstringWhen it last changed.
idsarrayEvery track's ID, in order, including any the requester cannot see.
tracksarrayThe tracks the requester can see, in the track shape, in order.
tracks[].idstringThe attachment ID, or "url:" and a hash for a file outside the Media Library.
tracks[].srcstring
tracks[].typestring One of audio, video.
tracks[].titlestring
tracks[].artiststring
tracks[].albumstring
tracks[].yearintegerThe year from the file's tags, or 0.
tracks[].discintegerWhich disc of a set the track is on, from the file's disc number tag (1 for "1/2"), or 0 when the tags do not say.
tracks[].durationnumberSeconds, 0 when unknown.
tracks[].langstringThe language of the title and artist, as a lang attribute takes it, from the file's tags; empty when the file does not say.
tracks[].formatstringThe container, lower case, as WordPress read it from the file: mp3, flac, m4a. Empty when unknown.
tracks[].bitrateintegerKilobits per second, 0 when unknown.
tracks[].losslessbooleanWhether the encoding is lossless.
tracks[].bitsintegerBits per sample, as WordPress read it from the file; 0 when the format does not say, as MP3 does not.
tracks[].rateintegerSamples per second, 0 when unknown.
tracks[].levelsstringThe track's loudness over time as digits 0 to 9, one per sample, when something has measured it; the drawn cover puts it in the groove. Empty otherwise.
tracks[].artarrayArtwork, smallest first.
tracks[].art[].srcstring
tracks[].art[].sizesstring
tracks[].art[].altstringWhat the picture shows, for a screen reader: the image's alt text, or the album and artist a drawn cover names.
tracks[].captionsarrayText tracks for a video: the WebVTT file its Captions field names, or the tracks its video block carries.
tracks[].captions[].srcstring
tracks[].captions[].labelstring
tracks[].captions[].srclangstring
tracks[].captions[].kindstring One of captions, subtitles, descriptions.
tracks[].videoobject | null
tracks[].video.srcstring
tracks[].video.posterstring
tracks[].video.captionsarray
tracks[].video.captions[].srcstring
tracks[].video.captions[].labelstring
tracks[].video.captions[].srclangstring
tracks[].video.captions[].kindstring One of captions, subtitles, descriptions.
tracks[].postobject | null
tracks[].post.idinteger
tracks[].post.titlestring
tracks[].post.urlstring
tracks[].lockedbooleanWhether the current visitor may not play the track, as riff_can_play decided. A locked track has no src.
tracks[].unlockstringWhere a locked track sends the visitor to unlock it, from riff_unlock_url. Empty otherwise.
tracks[].indexintegerThe track's place in the playlist, from 0.

WPGraphQL

When WPGraphQL is active, Riff adds these fields and types.

FieldDescription
MediaItem.riffTrackRiffTrackThe file as a track, for audio and video.
Post.riffTracks[RiffTrack]The tracks in the post, in order.

RiffArt

One size of a track's artwork.

FieldType
srcString
sizesString
altString

RiffCaptions

FieldType
srcString
labelString
srclangString
kindString

RiffVideo

The video version of an audio track.

FieldType
srcString
posterString
captions[RiffCaptions]

RiffPost

The post a track appears in.

FieldType
idInt
titleString
urlString

RiffTrack

A file as a track the Riff player reads.

FieldType
idString
srcString
typeString
titleString
artistString
albumString
yearInt
discInt
durationFloat
langString
formatString
bitrateInt
losslessBoolean
bitsInt
rateInt
levelsString
art[RiffArt]
captions[RiffCaptions]
videoRiffVideo
postRiffPost
lockedBoolean
unlockString