Requests
Request a song
POST
/api/requestsOpen. Open to everyone who can reach Tempolight.
Asks for a song. The same song again adds a vote instead (merged: true). At most 30 a minute.
Request body application/json
titlestringrequiredUp to 120 characters
bystringUp to 40 characters
Responses
200OKapplication/json
idstringr…
titlestringbystringvotesintegeratnumberWhen it was asked for (ms).
donebooleanmergedbooleanThe same song was asked for already: a vote was added.
400The body isn't valid JSON, or a value is wrong.application/json
errorstringrequiredWhat went wrong, in a sentence for people.
403Locked, or not allowed.application/json
errorstringrequiredWhat went wrong, in a sentence for people.
429Too many calls; wait a little.application/json
errorstringrequiredWhat went wrong, in a sentence for people.
Request
curl -X POST 'http://localhost:8080/api/requests' \
-H 'content-type: application/json' \
-d '{
"title": "Daft Punk – One More Time",
"by": "Sam"
}'const res = await fetch("http://localhost:8080/api/requests", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
"title": "Daft Punk – One More Time",
"by": "Sam"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"http://localhost:8080/api/requests",
json={
"title": "Daft Punk – One More Time",
"by": "Sam"
},
)
print(res.json())Response
{
"id": "r2k8d1",
"title": "Daft Punk – One More Time",
"by": "Sam",
"votes": 3,
"at": 1762200000000
}{
"error": "Type a song, for example: Daft Punk – One More Time"
}{
"error": "Song requests are turned off"
}{
"error": "Lots of requests right now. Try again in a minute."
}