The Airtime API is available here for programmers that are designing custom apps, widgets and websites designed to work with Airtime Pro. In order for your custom widgets to be able to access the API, you will need to enable the Public Airtime API in your Airtime Settings menu. (pictured below).
Introduction
Airtime features a public HTTP API that allows you to retrieve JSON-encoded information about a station and what's currently playing.
To invoke an API, make an HTTP request to:
http://my-airtime-station/api/live-info
Live Info API
live-info
Note: The live-info-v2 API below is slightly easier to use. We recommend using that API instead.
The current (as of 2.5.1) live-info API provides the user with a JSON encoded object containing track, show, and station data.
eg. http://sourcefabric.airtime.pro/api/live-info
{ "env": "production", "schedulerTime": "2017-01-05 21:44:48", "previous": { "starts": "2017-01-05 21:39:23.000000", "ends": "2017-01-05 21:42:10.000000", "type": "track", "name": "Al Di Meola - Eleanor Rigby", "metadata": { "id": 7531, "name": "", "mime": "audio\/mp3", "ftype": "audioclip", "directory": null, "filepath": "57459b5924f48-al-di-meola-eleanor-rigby.mp3", "import_status": 0, "currentlyaccessing": 0, "editedby": null, "mtime": "2016-05-25 12:32:36", "utime": "2016-05-25 12:32:25", "lptime": "2017-01-05 21:39:24", "track_title": "Eleanor Rigby", "artist_name": "Al Di Meola", ... } }, "current": { "starts": "2017-01-05 21:42:08", "ends": "2017-01-05 21:48:48", "type": "track", "name": "Ryan Keberle - Big Kick Blues", "media_item_played": true, "metadata": {...}, "record": "0" }, "next": { "starts": "2017-01-05 21:48:46.000000", "ends": "2017-01-05 21:53:24.000000", "type": "track", "name": "Eric van Aro - I'm not anyone feat. Fabio Gianni", "metadata": {...} }, "currentShow": [ { "start_timestamp": "2017-01-05 13:00:00", "end_timestamp": "2017-01-06 13:00:00", "name": "Auto DJ Show", "description": "", "id": 915, "instance_id": 15794, "record": 0, "url": "", "image_path": "", "image_cloud_file_id": null, "starts": "2017-01-05 13:00:00", "ends": "2017-01-06 13:00:00" } ], "nextShow": [ { "id": 916, "instance_id": 15795, "name": "Auto DJ Show", "description": "", "url": "", "start_timestamp": "2017-01-06 13:00:00", "end_timestamp": "2017-01-07 13:00:00", "starts": "2017-01-06 13:00:00", "ends": "2017-01-07 13:00:00", "record": 0, "image_path": "", "image_cloud_file_id": null, "type": "show" } ], "source_enabled": "Scheduled", "timezone": "Europe\/London", "timezoneOffset": "0", "AIRTIME_API_VERSION": "1.1" }
This format supports the following parameters:
type
api/live-info?type=endofday - provides information on shows until the end of the current day, in the station timezone
api/live-info?type=interval - default; provides information for a 48 hour interval from the current time
limit
api/live-info?limit=n - limits the number of shows returned by the request. The defaults is 5
callback
api/live-info?callback=myFunction - passes a user-defined function as JSONP padding to call on the JSON response
live-info-v2
Changes to live-info (currently in-progress as live-info-v2) will change this format to the following:
eg. http://sourcefabric.airtime.pro/api/live-info-v2
{ "station": { "env": "production", "schedulerTime": "2017-01-05 21:51:59", "source_enabled": "Scheduled", "timezone": "Europe\/London", "AIRTIME_API_VERSION": "1.1" }, "tracks": { "previous": { "starts": "2017-01-05 21:42:08", "ends": "2017-01-05 21:48:48", "type": "track", "name": "Ryan Keberle - Big Kick Blues", "metadata": { "id": 7683, "name": "", "mime": "audio\/mp3", "ftype": "audioclip", "directory": null, "filepath": "57581e5fc4f44-big-kick-blues.mp3", "import_status": 0, "currentlyaccessing": 0, "editedby": null, "mtime": "2016-06-08 13:32:21", "utime": "2016-06-08 13:32:15", "lptime": "2017-01-05 21:42:09", "track_title": "Big Kick Blues", "artist_name": "Ryan Keberle",
... } }, "current": { "starts": "2017-01-05 21:48:46", "ends": "2017-01-05 21:53:24", "type": "track", "name": "Eric van Aro - I'm not anyone feat. Fabio Gianni", "media_item_played": true, "metadata": { "id": 7563, "name": "", "mime": "audio\/mp3", "ftype": "audioclip", "directory": null, "filepath": "57459d382a9b8-eric-van-aro-im-not-anyone.mp3", "import_status": 0, "currentlyaccessing": 0, "editedby": null, "mtime": "2016-05-25 12:40:40", "utime": "2016-05-25 12:40:24", "lptime": "2017-01-05 21:48:47", "track_title": "I'm not anyone feat. Fabio Gianni", "artist_name": "Eric van Aro", ... }, "record": "0" }, "next": { "starts": "2017-01-05 21:53:22", "ends": "2017-01-05 21:57:33", "type": "track", "name": "Ray Sandoval - 'Round Midnight", "metadata": { "id": 7605, "name": "", "mime": "audio\/mp3", "ftype": "audioclip", "directory": null, "filepath": "57459ff11f9e8-ray-sandoval-round-midnight_song-version.mp3", "import_status": 0, "currentlyaccessing": 0, "editedby": null, "mtime": "2016-05-25 12:52:05", "utime": "2016-05-25 12:52:01", "lptime": "2017-01-05 11:51:54", "track_title": "'Round Midnight", "artist_name": "Ray Sandoval",
... } } }, "shows": { "previous": [ { "name": "Auto DJ Show", "description": "", "genre": "", "id": 914, "instance_id": 15793, "record": 0, "url": "", "image_path": "", "image_cloud_file_id": null, "starts": "2017-01-04 13:00:00", "ends": "2017-01-05 13:00:00" } ], "current": { "name": "Auto DJ Show", "description": "", "genre": "", "id": 915, "instance_id": 15794, "record": 0, "url": "", "image_path": "", "image_cloud_file_id": null, "starts": "2017-01-05 13:00:00", "ends": "2017-01-06 13:00:00" }, "next": [ { "name": "Auto DJ Show", "description": "", "genre": "", "id": 916, "instance_id": 15795, "record": 0, "url": "", "image_path": "", "image_cloud_file_id": null, "starts": "2017-01-06 13:00:00", "ends": "2017-01-07 13:00:00" } ] } }
This new format will support the following parameters:
timezone
api/live-info-v2?timezone=est - specifies the timezone that the returned information should be converted to. The default is the station timezone
Timezones can be provided in abbreviated or full form (America/Toronto), and support all PHP-supported timezones.
The timezone parameter is case-insensitive.
days
api/live-info-v2?days=n - specifies the number of days of shows to return. The default is 2 days.
Note that days are defined until the end of day in the specified timezone, so days=1 will return show information for shows starting before the end of the current day, days=2 will return show information for shows starting before the end of the following day, and so on.
If this parameter is omitted, the API returns the next 2 days of shows by default.
shows
api/live-info-v2?shows=n - specifies the number of shows in the future to return. The default is 5.
Shows returned are prioritized in the following way: current show first, followed by upcoming ("next") shows within the interval defined by the days parameter, followed by shows ("previous") within the past 48 hours.
If this parameter is omitted, the API returns the next 5 shows by default.
callback
api/live-info-v2?callback - the callback parameter will remain unchanged from version 2.5.1
Week Info (Schedule) API
week-info
The week-info API call provides the user with a JSON encoded object containing track, show, and station data.
eg. http://sourcefabric.airtime.pro/api/week-info
{ "monday": [ { "start_timestamp": "2017-01-02 13:00:00", "end_timestamp": "2017-01-03 13:00:00", "name": "Auto DJ Show", "description": "", "id": 912, "instance_id": 15791, "instance_description": "", "record": 0, "url": "https://www.airtime.pro/", "image_path": "", "image_cloud_file_id": null, "starts": "2017-01-02 13:00:00", "ends": "2017-01-03 13:00:00" } ], "tuesday": [ { "start_timestamp": "2017-01-03 13:00:00", "end_timestamp": "2017-01-04 13:00:00", "name": "Auto DJ Show", "description": "", "id": 913, "instance_id": 15792, "instance_description": "", "record": 0, "url": "https://www.airtime.pro/", "image_path": "", "image_cloud_file_id": null, "starts": "2017-01-03 13:00:00", "ends": "2017-01-04 13:00:00" } ], "wednesday": [ { "start_timestamp": "2017-01-04 13:00:00", "end_timestamp": "2017-01-05 13:00:00", "name": "Auto DJ Show", "description": "", "id": 914, "instance_id": 15793, "instance_description": "", "record": 0, "url": "", "image_path": "", "image_cloud_file_id": null, "starts": "2017-01-04 13:00:00", "ends": "2017-01-05 13:00:00" } ], "thursday": [ { "start_timestamp": "2017-01-05 13:00:00", "end_timestamp": "2017-01-06 13:00:00", "name": "Auto DJ Show", "description": "", "id": 915, "instance_id": 15794, "instance_description": "", "record": 0, "url": "", "image_path": "", "image_cloud_file_id": null, "starts": "2017-01-05 13:00:00", "ends": "2017-01-06 13:00:00" } ], "friday": [ { "start_timestamp": "2017-01-06 13:00:00", "end_timestamp": "2017-01-07 13:00:00", "name": "Auto DJ Show", "description": "", "id": 916, "instance_id": 15795, "instance_description": "", "record": 0, "url": "", "image_path": "", "image_cloud_file_id": null, "starts": "2017-01-06 13:00:00", "ends": "2017-01-07 13:00:00" } ], "saturday": [ ], "sunday": [ ], "nextmonday": [ ], "nexttuesday": [ ], "nextwednesday": [ ], "nextthursday": [ ], "nextfriday": [ ], "nextsaturday": [ ], "nextsunday": [ ], "AIRTIME_API_VERSION": "1.1" }
This format will support the following parameters:
timezone
api/week-info?timezone=est - specifies the timezone that the returned information should be converted to. The default is the station timezone
Timezones can be provided in abbreviated or full form (America/Toronto), and support all PHP-supported timezones.
The timezone parameter is case-insensitive.
callback
api/week-info?callback=myFunction - passes a user-defined function as JSONP padding to call on the JSON response
Station Metadata API
station-metadata
The station-metadata API call provides static information about the station.
eg. http://sourcefabric.airtime.pro/api/station-metadata
{ "name": "Sourcefabric 90.8 FM", "logo": "http:\/\/sourcefabric.airtime.pro:80\/api\/station-logo", "description": "Proudly powered by Airtime Pro!", "timezone": "Europe\/London", "locale": "en_CA", "stream_data": { "s2": { "url": "http:\/\/sourcefabric.out.airtime.pro:8000\/sourcefabric_b", "codec": "mp3", "bitrate": 64, "mobile": "1" }, "s1": { "url": "http:\/\/sourcefabric.out.airtime.pro:8000\/sourcefabric_a", "codec": "mp3", "bitrate": 192, "mobile": "0" } }, "AIRTIME_API_VERSION": "1.1" }
Station Logo API
station-logo
The station-metadata API is a read-only URL that returns the radio station's logo.
eg. http://sourcefabric.airtime.pro/api/station-logo
Shows API
shows
The shows API is a read-only URL that returns the list of shows on the station.
eg. http://sourcefabric.airtime.pro/api/shows
[ { "name": "The DJ DJ Show", "id": 1, "url": "http:\/\/www.64studio.com\/", "genre": "Funk", "description": "Give up the funk, baby!", "color": "000000", "background_color": "75bc0c", "linked": false }, { "name": "DJ SmiLing", "id": 2, "url": "", "genre": "", "description": "Beata rocks the house!", "color": "000000", "background_color": "00f82b", "linked": false },
....
]
This format will support the following parameters:
show_id
api/shows?show_id=1245
Show Logo API
Retrieves the logo for the show with the given ID. Redirects to the station logo if the show has no logo.
eg. http://sourcefabric.airtime.pro/api/show-logo?id=1
Parameters:
id (int) - Show ID
Playout History Feed API
Retrives a list of past played tracks and the times they were played at.
eg. http://sourcefabric.airtime.pro/api/item-history-feed
HTTP Method: GET
Parameters:
start (timestamp) - Start of date range (eg. 2016-04-05 00:00:00)
end (timestamp) - End of date range (eg. 2016-04-07 00:00:00)
timezone - Optional - The timezone that all returned data will be in.
instance_id (int) - Optional - The ID of the show instance to filter data by.
eg. https://sourcefabric.airtime.pro/api/item-history-feed?start=2016-06-22%2020:10:00&end=2016-06-27
Response:
[{"starts":"2016-06-22 14:07:55","ends":"2016-06-22 14:10:59","history_id":22342,"instance_id":33704,"track_title":"Some great track","artist_name":"Artsy McArtface","copyright":null},
{"starts":"2016-06-22 14:10:59","ends":"2016-06-22 14:14:43","history_id":22343,"instance_id":33704,"track_title":"Another great track","artist_name":"Art Guy","copyright":null},
{"starts":"2016-06-22 14:12:49","ends":"2016-06-22 14:17:03","history_id":22344,"instance_id":33704,"track_title":"Meh Track","artist_name":"Some Guy","copyright":null},
{"starts":"2016-06-22 14:17:03","ends":"2016-06-22 14:20:27","history_id":22345,"instance_id":33704,"track_title":"Super Duper Track","artist_name":"Example Artist","copyright":null},
{"starts":"2016-06-22 14:20:27","ends":"2016-06-22 14:23:55","history_id":22346,"instance_id":33704,"track_title":"You won't believe it\'s track!","artist_name":"Some Artist","copyright":null},
.... }]
Show Tracks API
/api/show-tracks
Retrieves a list of tracks in a given show instance.
eg. https://sourcefabric.airtime.pro/api/show-tracks?instance_id=15798
This format will support the following required parameter:
instance_id
api/show-tracks?instance_id=15798 - specifies the show instance id to return a track listing of
[{"title":"The City feat. Kelli Sae","artist":"Count Basic","position":0,"id":1,"mime":"audio\/mp3","starts":"2017-01-09 13:00:00","length":"3:41.8","file_id":7559},
{"title":"Lover's Groove","artist":"Farnell Newton Marcus Reynolds Quintet","position":1,"id":2,"mime":"audio\/mp3","starts":"2017-01-09 13:03:37","length":"7:30.0","file_id":7719},
{"title":"Penny Lane","artist":"Al Di Meola","position":2,"id":3,"mime":"audio\/mp3","starts":"2017-01-09 13:11:01","length":"5:42.0","file_id":7537},
{"title":"Cristal feat. Nelson Gonz\u00e1lez","artist":"Danny Rivera","position":3,"id":4,"mime":"audio\/mp3","starts":"2017-01-09 13:16:36","length":"3:50.3","file_id":7639},
{"title":"El Vendedor feat. Satin Singh","artist":"Ray Sandoval","position":4,"id":5,"mime":"audio\/mp3","starts":"2017-01-09 13:20:19","length":"4:31.4","file_id":7597},
...
]
Show Schedules API
show-schedules
Retrieves a list of show instances for a given show.
eg. https://sourcefabric.airtime.pro/api/show-schedules?show_id=919
This format will support the following required parameter:
show_id
api/show-schedules?show_id=919 - specifies the show id to return a list of its show instances
[
{
"starts":"2017-01-09 13:00:00",
"ends":"2017-01-10 13:00:00",
"record":0,
"rebroadcast":0,
"parent_starts":null,
"record_id":null,
"show_id":919,
"name":"Auto DJ Show",
"description":"",
"color":"",
"background_color":"",
"image_path":"",
"image_cloud_file_id":null,
"linked":false,
"auto_dj":true,
"rotation":6,
"file_id":null,
"instance_id":15798,
"instance_description":"",
"created":"2017-01-08 13:04:45",
"last_scheduled":"2017-01-09 12:00:38",
"time_filled":"24:10:11.460355",
"instance_rotation":-2,
"rotation_scheduled":true,
"soundcloud_id":null
}]
0 Comments