Complete API reference with request examples using fetch and curl
TimeSpeaker provides two main endpoints for generating and retrieving time audio files:
/api/audio - Generate or retrieve time audio /api/session - Get current session information Generates or retrieves cached audio of the current time.
language
Language code (pt-BR, en, es). Default: en
timezone
Timezone identifier (e.g., America/Sao_Paulo). Default: UTC
Accept
audio/mpeg returns audio file application/json returns JSON with URL
Authorization (optional)
Bearer token for higher rate limits
// Get audio file
fetch('/api/audio?language=pt-BR&timezone=America/Sao_Paulo', {
headers: {
'Accept': 'audio/mpeg'
}
})
.then(response => response.blob())
.then(blob => {
const audio = new Audio(URL.createObjectURL(blob));
audio.play();
})
.catch(error => console.error('Error:', error));
// Get JSON response with URL
fetch('/api/audio?language=en&timezone=UTC', {
headers: {
'Accept': 'application/json'
}
})
.then(response => response.json())
.then(data => {
console.log('Audio URL:', data.url);
console.log('Language:', data.language);
console.log('Timezone:', data.timezone);
console.log('Time:', data.time);
})
.catch(error => console.error('Error:', error));# Download audio file
curl -H "Accept: audio/mpeg" \
"http://localhost:3000/api/audio?language=pt-BR&timezone=America/Sao_Paulo" \
--output time.mp3
# Get JSON response
curl -H "Accept: application/json" \
"http://localhost:3000/api/audio?language=en&timezone=UTC"
# With authentication
curl -H "Accept: audio/mpeg" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "App-Id: YOUR_UUID" \
"http://localhost:3000/api/audio?language=es&timezone=Europe/Madrid"JSON Response (Accept: application/json):
{
"url": "/audio-cache/abc123def456.mp3",
"language": "pt-BR",
"timezone": "America/Sao_Paulo",
"time": "14:30"
}Audio Response (Accept: audio/mpeg):
Binary audio file (MP3 format)
Returns current session information based on request context.
language (optional)
Override language detection
timezone (optional)
Override timezone detection
// Get session info with auto-detection
fetch('/api/session')
.then(response => response.json())
.then(data => {
console.log('Detected Language:', data.language);
console.log('Detected Timezone:', data.timezone);
console.log('Current Time:', data.currentTime);
})
.catch(error => console.error('Error:', error));
// Override detection
fetch('/api/session?language=pt-BR&timezone=America/Sao_Paulo')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));# Auto-detect session
curl "http://localhost:3000/api/session"
# With overrides
curl "http://localhost:3000/api/session?language=es&timezone=Europe/Madrid"
# With Accept-Language header
curl -H "Accept-Language: pt-BR" \
"http://localhost:3000/api/session"{
"language": "pt-BR",
"timezone": "America/Sao_Paulo",
"currentTime": "2025-11-30T14:30:00-03:00"
}Unauthenticated Requests
5 requests per minute per IP address
Authenticated Requests
20 requests per minute per IP address
429 Too Many Requests: When rate limit is exceeded, the API will return HTTP 429 with a message indicating the limit has been reached.
pt-BR - Português (Brasil) en - English es - Español UTC America/Sao_Paulo America/New_YorkEurope/LondonAsia/Tokyo