🚀 Quick Start
Base URL for all API requests:
For Mobile Developers
All mobile apps should use https://api.themegaradio.com as the base URL. Web browsers use https://themegaradio.com with built-in API proxy.
Fetch popular stations with a single request:
const response = await fetch('https://api.themegaradio.com/api/stations/popular?limit=20');
const stations = await response.json();
// Each station object:
// { name, url, urlResolved, country, favicon, votes, codec, bitrate, slug, ... }
curl https://api.themegaradio.com/api/stations/popular?limit=10
🔐 Authentication
Three ways to authenticate API requests:
| Method | Header | Use Case |
|---|---|---|
| API Key | X-API-Key: your_key | Server-to-server, mobile apps |
| User Token | X-API-User-Token: token | Per-user actions (favorites, ratings) |
| Session Cookie | Cookie: connect.sid=... | Web browser (auto-managed) |
API Key Tiers
Demo
Free
Pro
const res = await fetch('https://api.themegaradio.com/api/api-keys/demo', { method: 'POST' });
const { apiKey } = await res.json();
// Use the API key
fetch('https://api.themegaradio.com/api/stations/popular', {
headers: { 'X-API-Key': apiKey }
});
📻 Stations
Browse, search, and discover 40,000+ radio stations.
Query Parameters for /api/stations
| Param | Type | Description |
|---|---|---|
q | string | Search query (name, tags, country) |
country | string | Filter by country name |
genre | string | Filter by genre/tag |
codec | string | Filter by codec (MP3, AAC, OGG) |
limit | number | Results per page (default: 20, max: 100) |
offset | number | Pagination offset |
sort | string | Sort: votes, clickCount, name, random |
fetch('https://api.themegaradio.com/api/stations?q=jazz&country=Germany&limit=10')
🎶 Genres & Countries
🎧 Streaming
Stream proxy handles CORS, HTTPS upgrades, and ICY metadata extraction.
Smart Streaming Logic
- HTTPS streams: Play directly in the client (no proxy needed)
- HTTP streams: Must use the proxy for CORS and mixed-content safety
- Stream URL must be URL-encoded in the path:
/api/stream/http%3A%2F%2Fexample.com%2Fstream
const station = await fetch('https://api.themegaradio.com/api/station/mangoradio').then(r => r.json());
const streamUrl = station.url.startsWith('https')
? station.url // Direct HTTPS — no proxy needed
: `https://api.themegaradio.com/api/stream/${encodeURIComponent(station.url)}`;
// Use streamUrl in your audio player (e.g., react-native-track-player)
⭐ User Engagement
Favorites, ratings, follows, and trending data. Requires authentication.
👤 User Authentication
const res = await fetch('https://api.themegaradio.com/api/auth/google', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
idToken: 'google_id_token_here',
email: '[email protected]',
name: 'User Name',
googleId: 'google_user_id'
})
});
💰 Subscription (Mobile IAP)
Report and verify in-app purchases from iOS/Android.
Product IDs
| Product ID | Plan | Features |
|---|---|---|
megaradio_remove_ads_yearly1 | Remove Ads | Ad-free experience |
megaradio_premium_monthly1 | Premium Monthly | All features |
megaradio_premium_yearly | Premium Yearly | All features |
megaradio_premium_lifetime | Premium Lifetime | All features, forever |
await fetch('https://api.themegaradio.com/api/user/subscription', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-User-Token': userToken
},
body: JSON.stringify({
productId: 'megaradio_premium_monthly1',
transactionId: 'GPA.1234-5678',
platform: 'android' // or 'ios'
})
});
⚡ WebSocket
Real-time connections for live metadata and casting.
const ws = new WebSocket('wss://api.themegaradio.com/ws/metadata');
ws.onopen = () => {
ws.send(JSON.stringify({ type: 'subscribe', stationId: 'station_id_here' }));
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log(`Now playing: ${data.title} - ${data.artist}`);
};
📺 Cast & TV
Chromecast, TV app, and device code login support.
🛡 Rate Limits
| Scope | Limit | Window |
|---|---|---|
| Global API | 100 requests | 1 minute |
| Auth endpoints (login/register) | 10 attempts | 15 minutes |
| Demo API Key | 50 requests | 24 hours |
| Free API Key | 1,000 requests | 24 hours |
| Pro API Key | 50,000 requests | 24 hours |
Rate Limit Response
When rate limited, the API returns 429 Too Many Requests with a Retry-After header indicating when to retry.
⚠️ Error Handling
All errors follow a consistent JSON format:
"error": "Human-readable error message",
"message": "Detailed description (optional)"
}
| Status | Meaning |
|---|---|
200 | Success |
400 | Bad request (invalid params) |
401 | Unauthorized (missing/invalid auth) |
403 | Forbidden (insufficient permissions) |
404 | Not found |
429 | Rate limited |
500 | Internal server error |