Retry×

Developers / Mixcloud API documentation

Create new application

Introduction

The Mixcloud API has been designed to be simple to use and familiar. This page has all of the information you need to get going.

Documentation for the Widget Javascript API can be found here.

Contents

Cloudcasts, Users etc

Objects in the Mixcloud API can be found by taking the URL where you would find them on the site and changing http://www.mixcloud.com/ to http://api.mixcloud.com/.

Take a look at the following links in a browser to see example responses:

Cloudcasthttp://api.mixcloud.com/spartacus/party-time/
Userhttp://api.mixcloud.com/spartacus/
Taghttp://api.mixcloud.com/tag/funk/
Artisthttp://api.mixcloud.com/artist/aphex-twin/
Trackhttp://api.mixcloud.com/track/michael-jackson/everybody/
Featured categoryhttp://api.mixcloud.com/categories/ambient-chillout/

For example http://api.mixcloud.com/artist/aphex-twin/ {
    "url": "http://www.mixcloud.com/artist/aphex-twin/",
    "name": "Aphex Twin",
    "key": "/artist/aphex-twin/",
    "slug": "aphex-twin"
}

JSONP is supported. Adding a callback query string parameter with the name of a function wraps the response - for example http://api.mixcloud.com/artist/aphex-twin/?callback=callbackfn callbackfn({
    "url": "http://www.mixcloud.com/artist/aphex-twin/",
    "name": "Aphex Twin",
    "key": "/artist/aphex-twin/",
    "slug": "aphex-twin"
})

Each object has a key which is the URL (from the first /) to the object in the API.

Connections and lists

To find out the available connections for an object add metadata=1 to the query string - for example http://api.mixcloud.com/spartacus/?metadata=1 {
...
    "metadata": {
        "connections": {
            "feed": "http://api.mixcloud.com/spartacus/feed/",
            "comments": "http://api.mixcloud.com/spartacus/comments/",
            "followers": "http://api.mixcloud.com/spartacus/followers/",
            "favorites": "http://api.mixcloud.com/spartacus/favorites/",
            "following": "http://api.mixcloud.com/spartacus/following/",
            "cloudcasts": "http://api.mixcloud.com/spartacus/cloudcasts/",
            "listens": "http://api.mixcloud.com/spartacus/listens/"
        }
    },
    "type": "user",
...
}

Most connections return lists of items. Other available lists are:

Popularhttp://api.mixcloud.com/popular/
Hothttp://api.mixcloud.com/popular/hot/
Newhttp://api.mixcloud.com/new/

Paging

limit and offset query string parameters can be used to page lists.

Lists of items with dates (such as Cloudcasts) can be paged using since and until query string parameters. These parameters accept either Unix timestamps (the number of seconds since 1970-1-1) or UTC date times of the format YYYY-MM-DD HH:MM:SS.

When a list is returned URLs for the previous and next pages are provided in the response. If you would like the paging links to use offset rather than defaulting to dates, add offset=0 to the first request.

Me

The URL http://api.mixcloud.com/me/ is a shortcut to the authorized user's information and connections. /me/ URLs are only available over https with an access token (see the Authorization section for more information).

The /search/ URL can be used to perform searches across Cloudcasts, Users and Tags using the following URL with a type query string parameter which is either cloudcast, user or tag and a q parameter with the search string - for example http://api.mixcloud.com/search/?q=party+time&type=cloudcast

Authorization

Access tokens are required to update any data or use the /me/ shortcut and must only be provided across https connections.

Extra information is added to some objects if an access token is provided - for example a following attribute is added to a User object to indicate whether or not the authorized user is following the requested User.

The Mixcloud API uses OAuth2 for authorization.

Getting an access token

First you'll need to create and application. Then you will be assigned a client_id and client_secret.

Only browser based authorization is supported currently. Redirect your user to
https://www.mixcloud.com/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI
where they will be given the option to log in and allow or deny your application access to their data.

If the user accepts Mixcloud will redirect the user to YOUR_REDIRECT_URI?code=OAUTH_CODE.

Once you have received the OAUTH_CODE send a request to
https://www.mixcloud.com/oauth/access_token?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&client_secret=YOUR_CLIENT_SECRET&code=OAUTH_CODE.
This will respond with an access token: access_token=YOUR_ACCESS_TOKEN which can be used on future requests as an access_token query string parameter to access protected resources.

Note it is possible for the user to revoke their access token so your application will need to handle "An invalid access token was provided" errors and re-authenticate the user.

Following and Favoriting

The URL for following is a User API key with follow/ on the end - for example https://api.mixcloud.com/spartacus/follow/?access_token=ACCESS_TOKEN

The URL for favoriting is a Cloudcast API key with favorite/ on the end - for example https://api.mixcloud.com/spartacus/party-time/favorite/?access_token=ACCESS_TOKEN

To follow or favorite an access token is required. Simply send a POST request to the URL to follow/favorite and a DELETE request to unfollow/unfavorite. It is also possible to send a POST request with a parameter of method=delete to simulate a DELETE request.

For example: curl -X POST "https://api.mixcloud.com/spartacus/follow/?access_token=ACCESS_TOKEN" curl -X DELETE "https://api.mixcloud.com/spartacus/follow/?access_token=ACCESS_TOKEN" curl -F "method=delete" "https://api.mixcloud.com/spartacus/follow/?access_token=ACCESS_TOKEN"

Embedding

Embed code for the widget can be retrieved by adding embed-html/ to a Cloudcast API key - for example http://api.mixcloud.com/spartacus/party-time/embed-html/. JavaScript applications (requiring JSONP for cross domain requests) can use embed-json/ instead of embed-html/ to get the HTML wrapped in JSON. width, height and color (6 digit hex code) query parameters can be used to change the widget's appearance.

Mixcloud also supports oEmbed discovery. For example you can get the embed code for a cloudcast like this:
http://www.mixcloud.com/oembed/?url=http%3A//www.mixcloud.com/spartacus/party-time/&format=json

Uploads

Cloudcasts can be uploaded by posting to https://api.mixcloud.com/upload/ with an access token (see the Authorization section).

The MP3, metadata and image should all be uploaded in a single multipart/form-data POST. The same filesize and metadata restrictions apply as in the standard Mixcloud web interface so it is recommended that applications using the Mixcloud API validate the data before sending since the user will have to wait for the MP3 to be uploaded before any validation errors are returned.

The available fields and their restrictions are shown in the table below. Fields labelled REQUIRED are required - all other fields are optional.

mp3REQUIRED. The audio file to be uploaded. The file should not be larger than 524288000 bytes.
nameREQUIRED. The name of the cloudcast - this will be used to generate the URL, duplicate names should be avoided but will not cause an upload to fail.
pictureA picture for the cloudcast. The file should not be larger than 10485760 bytes.
descriptionA description for the cloudcast. Maximum of 1000 characters.
tags-X-tagWhere X is a number 0-4, a tag name for the cloudcast. Up to 5 tags can be provided.
publish_dateONLY FOR UPLOADING TO PRO ACCOUNTS. Scheduled publish date for the upload in the format YYYY-MM-DD:THH:MM:SSZ (e.g. 2015-11-21T14:05:00Z). Note: the date MUST be UTC so you may need to convert for your local timezone first.

Tracklist/chapter information is provided using the fields in the table below where X represents the section (track or chapter) number - starting with 0.

sections-X-artistREQUIRED (if a track). The track section artist name.
sections-X-songREQUIRED (if a track). The track section song title.
sections-X-chapterThe name of a chapter section.
sections-X-start_timeThe time, in seconds (integer), at which section X starts.

An example, using curl, is shown below uploading an MP3 called "cloudcast.mp3", with a name of "API Upload", 2 tags ("Test" and "API"), 2 sections (a chapter called "Introduction" and one track) and an image called "cloudcast.jpg". curl -F mp3=@cloudcast.mp3 \
     -F "name=API Upload" \
     -F "tags-0-tag=Test" \
     -F "tags-1-tag=API" \
     -F "sections-0-chapter=Introduction" \
     -F "sections-0-start_time=0" \
     -F "sections-1-artist=Artist Name" \
     -F "sections-1-song=Song Title" \
     -F "sections-1-start_time=10" \
     -F "description=My test cloudcast" \
     https://api.mixcloud.com/upload/?access_token=INSERT_ACCESS_TOKEN_HERE

Editing uploads

Cloudcasts can be edited by posting to https://api.mixcloud.com/upload[YOUR_CLOUDCAST_KEY]edit/ (e.g. https://api.mixcloud.com/upload/my-username/my-upload/edit/) with an access token (see the Authorization section). You can edit uploads that were not uploaded with the API.

The metadata and image should all be uploaded in a single multipart/form-data POST. All fields that are allowed in an upload except mp3 can be sent to this endpoint.

The name, description and picture fields will only be updated if they are included in the request (e.g. if the description parameter is not included the description of the upload will not be changed).

If any tag fields are posted all tags will be overwritten (if you want to just add a tag, you will have to post the tags that are already on the upload for them to remain). Also for sections if any section field is posted the entire tracklist will be overwritten.

An example, using curl, is shown below: curl -F picture=@mypicture.jpg \
     -F "name=A new name" \
     -F "tags-0-tag=Test" \
     -F "tags-1-tag=API" \
     -F "description=My test cloudcast" \
     https://api.mixcloud.com/upload/my-username/my-upload/edit/?access_token=INSERT_ACCESS_TOKEN_HERE

Rate limits

There are rate limits on all actions in the API. We're still tweaking these so if you keep hitting them, do let us know at api@mixcloud.com

The response in the rate limit tells you how long you have to wait until you can try again in both the HTTP headers and the JSON/XML response. HTTP/1.1 403 Forbidden
Retry-After: 452

{
    "error": {
        "message": "You have hit your rate limit. Retry after 452 seconds.",
        "type": "RateLimitException",
        "retry_after": 452
    }
}

Audio Streams

The audio streams are not available through the Mixcloud API. There are two reasons for this.

Firstly, we need to know what has been listened to so that we can report usage, pay royalties and provide features such as "Suggested Cloudcasts". Secondly, Mixcloud needs to pay the bills! We can't give away the audio for free outside of mixcloud.com simply because it costs us to host and stream the files and pay royalties.

The Mixcloud apps conform to the same structure as the website. Should you wish to link to a piece of Mixcloud content from your own app, you can link directly to that content in our app.

Converting a Mixcloud URL to an App Link

Almost all Mixcloud URLs can be viewed within our mobile apps. To generate a mixcloud mobile app link simply replace http://www.mixcloud.com with the url scheme mc://.

For example:

http://www.mixcloud.com/avici/

becomes

mc://avicii/ (on iOS)

mc://www.mixcloud.com/avicii/ (on Android)

Linking in iOS:

If you want to link to our app from your own app you can do so by using the code below. The code links to the content in the Mixcloud app if it is installed, else it will open the link in Safari.

Objective C:
NSString *urlPath = @"avicii/";
BOOL mixcloudInstalled = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"mc://"]];
NSString *urlRoot = @"http://www.mixcloud.com/";
if(mixcloudInstalled) {
    urlRoot = @"mc://";
}
NSURL *mixcloudURL = [NSURL URLWithString:[urlRoot stringByAppendingPathComponent:urlPath]];
[[UIApplication sharedApplication] openURL:mixcloudURL];
Swift:
let urlPath = "avicii/"
let mixcloudInstalled = UIApplication.sharedApplication().canOpenURL(NSURL(string:"mc://")
var urlRoot = "http://www.mixcloud.com/"
if(mixcloudInstalled) {
    urlRoot = "mc://"
}
let mixcloudURL = NSURL(string: urlRoot.stringByAppendingPathComponent(urlPath))
UIApplication.sharedApplication().openURL(mixcloudURL)

Linking in Android:

The android operating system will, by default, ask the user if they want to open a http://www.mixcloud.com link in the Mixcloud app if it is installed. This will automatically link to the relevant content with in the app. To always link to the Mixcloud app by default you can link using the mc:// url scheme. Below is some example code to do this:

Java:
String path = "avicii/";
try {
    Intent mixcloudIntent = new Intent(Intent.ACTION_VIEW);
    mixcloudIntent.setData(Uri.parse("mc://www.mixcloud.com/"+path));
    startActivity(mixcloudIntent);
} catch (ActivityNotFoundException e) {
    Intent mixcloudIntent = new Intent(Intent.ACTION_VIEW);
    mixcloudIntent.setData(Uri.parse("http://www.mixcloud.com/"+path));
    startActivity(mixcloudIntent);
}

Example

LazyDJ is a simple example of a website using the Mixcloud API. Check out the source at http://github.com/mixcloud/Mixcloud-LazyDJ.

Examples of people using the the Mixcloud API can be found at:

Let us know if you're using the API on:

api@mixcloud.com

We're hiring!

If you like hacking things together on APIs (particularly the Mixcloud API) you might like working for us. Check out our jobs page.

Oh snap, there was a playback error!

Press play to try again.

Streaming on Mixcloud requires Flash!

You can get it here.

[[player.currentCloudcast.title]]
By
Comment submitted
0:00:00
-0:00:00
Due to licensing issues in your country it will not be possible to seek backwards. Due to licensing issues in your country it is not possible to seek backwards. Why is this?
by   — BuyStarting in ...
  • This Cloudcast features tracks by , and more.
  • Find out why you’re not seeing the full tracklist.
  • By By
NEXT
To add Cloudcasts here use the buttons marked  
[[cloudcast.title]]
By
[[playerQueue.upNext.nextCloudcast.title]]
By