API

Usage

Radio Free offers an open API for developer access.  This API can be used to access the news wire, live stream, website pages, and more.  By accessing the API, you agree to Radio Free’s Terms of Use and Service.  Radio Free can revoke access at any time.  If you believe your access has been revoked or restricted, please email us.

Live Stream

https://radiofree.org/wp-json/wp/v2/album_art

This is the API endpoint to get live streaming data. Here is the example of result this endpoint will return:

{
“url”:”http:\/\/comet.shoutca.st:8731\/stream”,
“album”:”Mashrou’ Leila”,
“track”:”Ashabi”,
“artwork”:”http:\/\/is3.mzstatic.com\/image\/thumb\/Music117\/v4\/4a\/6b\/c6\/4a6bc6b4-7a09-7d4f-99d2-0cec72d7006b\/source\/500x500bb.jpg”
}

Menus

https://radiofree.org/wp-json/wp/v2/menus

This is the API endpoint to get any menu by it’s slug or name. Here is the example of result this endpoint will return (Though it’s JSON response so you have to JSON decode first)

array(        “footer-rss” => array(

“id” => 7629,
“slug” => “footer-rss”,
“name” => “Footer RSS”,
“items” => array(

array(229014,”RSS Feed”,”https://radiofree.org/feed/”,”custom”,0),
array(9231,”About”,”https://radiofree.org/about/”,”post_type”,3467),
array(425831,”News”,”https://radiofree.org/category/news/”,”taxonomy”,0),
)
)
)

Above is an example of data you will get from this endpoint. “footer-rss” is the wordpress menu which contain it’s ID and other information. In every menu you will find the “items” array which contains the menu items.

The 5th argument of menu item’s array tells you whether it’s internal link or external.  External returns “0”, otherwise it will return you the ID of that post/page/category.

The 4th argument tells the correct type of element if it’s post/category.

Posts/Pages

https://radiofree.org/wp-json/wp/v2/posts

https://radiofree.org/wp-json/wp/v2/posts/[post ID]

This is the endpoint to get the posts. It can also use to get post/page by ID. Here is the example of result this endpoint will return:

{
“id”:426844,
“date”:”2018-02-13T15:04:05″,
“date_gmt”:”2018-02-13T15:04:05″,
“guid”:{“rendered”:”https:\/\/radiofree.org\/announcing-the-2018-tiny-desk-contest\/”},
“modified”:”2018-02-13T15:04:05″,
“modified_gmt”:”2018-02-13T15:04:05″,
“slug”:”announcing-the-2018-tiny-desk-contest”,
“status”:”publish”,
“type”:”post”,
“link”:”https:\/\/radiofree.org\/announcing-the-2018-tiny-desk-contest\/”,
“title”:{“rendered”:”Announcing The 2018 Tiny Desk Contest”},
“content”:{“rendered”:””,”protected”:false},
“author”:101,
“featured_media”:426846,
“comment_status”:”open”,
“ping_status”:”open”,
“sticky”:false,
“template”:””,
“format”:”video”,
“meta”:{“amp_status”:””},
“categories”:[164],
“tags”:[21316,1329,21334]
}

For further info about this endpoint. Check WordPress API documentation page here http://v2.wp-api.org/reference/posts/

Categories

https://radiofree.org/wp-json/wp/v2/categories

https://radiofree.org/wp-json/wp/v2/categories/[category ID]

This is the endpoint to get all the categories of posts. You can also use get single category data by giving ID of the category. Here is the example of result this endpoint will return:

{
“id”:825,
“count”:0,
“description”:””,
“link”:”https:\/\/radiofree.org\/category\/autos-vehicles\/”,
“name”:”Autos & Vehicles”,
“slug”:”autos-vehicles”,
“taxonomy”:”category”,
“parent”:0,
“meta”:[],
“_links”:{
“self”:[{“href”:”https:\/\/radiofree.org\/wp-json\/wp\/v2\/categories\/825″}],
“collection”:[{“href”:”https:\/\/radiofree.org\/wp-json\/wp\/v2\/categories”}],
“about”:[{“href”:”https:\/\/radiofree.org\/wp-json\/wp\/v2\/taxonomies\/category”}],
“wp:post_type”:[{“href”:”https:\/\/radiofree.org\/wp-json\/wp\/v2\/posts?categories=825″}],
“curies”:[{“name”:”wp”,”href”:”https:\/\/api.w.org\/{rel}”,”templated”:true}]
}
}

For further info about this endpoint. Check WordPress API documentation page here http://v2.wp-api.org/reference/posts/