Getting Started
Create a partner account
To use the Moozar API, you first have to create a partner account.
Register your client(s)
Once registred and logged, in your dashboard, you need to generate a client id.
The client id is defined for your app / website and need a redirect url.
Authentication
Ask For an authorization code
Authorization is only needed for accessing users private informations, public datas ( such as artists or titles informations ) are not concerned.
If your app only need public access, you can skip this part and go directly to the Retrieve Data section.
If your app needs access to users private informations, you'll need an authorization token.
The authorization token is delivered for each users, if the user accept your app.
To prompt the user for the authorization, you have to build a request to the Moozar auth server, where the user can accept or refuse your app.
This request uses your client ID and redirect URI.
http://graph.moozar.com/firewall/auth?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}
$Moozar = new Moozar({APPLICATION_ID}, {CLIENT_ID}, {CLIENT_SECRET}, {REDIRECT_URI});
$Moozar->getAuthURL();
var Moozar = new Moozar({APPLICATION_ID}, {CLIENT_ID}, {CLIENT_SECRET}, {REDIRECT_URI});
Moozar.getAuthURL();
Moozar.init({
application_id: "{APPLICATION_ID}",
client_id: "{CLEINT_ID}",
client_secret: " {CLIENT_SECRET}",
redirect_uri: "{REDIRECT_URI}"
});
Moozar.login(function(response) {
if (response.isLog) {
Moozar.api('/me', function(user) {
console.log('Hello, ' + user.name + '!');
});
}
});
You can also add scopes to your request if you need specifics access to the user account.
All scopes & parameters can be find under the user section.
Here is a properly formed request using scopes.
http://graph.moozar.com/firewall/auth?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope=manage_playlist,reward_access
$Moozar = new Moozar({APPLICATION_ID}, {CLIENT_ID}, {CLIENT_SECRET}, {REDIRECT_URI});
$Moozar->getAuthURL(array('manage_playlist', 'reward_access'));
var Moozar = new Moozar({APPLICATION_ID}, {CLIENT_ID}, {CLIENT_SECRET}, {REDIRECT_URI});
Moozar.getAuthURL(['manage_playlist', 'reward_access']);
Moozar.init({
application_id: "{APPLICATION_ID}",
client_id: "{CLEINT_ID}",
client_secret: " {CLIENT_SECRET}",
redirect_uri: "{REDIRECT_URI}"
});
Moozar.login(function(response) {
if (response.isLog) {
Moozar.api('/me', function(user) {
console.log('Good to see you, ' + user.name + '.');
});
}
}, {scope: 'profile_info'});
Here we've asked permission to access playlist management and rewards informations.
If the user accept your app, he will be redirected to the redirect URI you've provided and return the authorization token which could be catched with a GET request.
Else, if the user refuse your app, you will be returned with an error / permission denied.
Ask For an access token
Now that you have an authorization token, this needs to be trade for an access token.
Usually, this just needs a POST request to http://graph.moozar.com/firewall/token including those parameters :
POST /firewall/token HTTP/1.1
Host: graph.moozar.com
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&
client_id={CLIENT_ID}&
client_secret={CLIENT_SECRET}&
redirect_uri={REDIRECT_URI}&
code={CODE}
$Moozar->getAccessToken();
Moozar.init({
application_id: "{APPLICATION_ID}",
client_id: "{CLEINT_ID}",
client_secret: " {CLIENT_SECRET}",
redirect_uri: "{REDIRECT_URI}"
});
Moozar.login(function(response) {
if (response.isLog) {
alert(response.access_token''+response.access_token+''+response.expired_in);
}
}, {scope: 'profile_info'});
This will return JSON encoded datas :
{
"access_token": {ACCESS_TOKEN}
"expired_in": 3600
"refresh_token": {REFRESH_TOKEN}
}
The access_token doesn't have a lifetime duration.
To check if your access_token is still valid, do a POST request to http://graph.moozar.com/firewall/token including those parameters:
POST /firewall/token HTTP/1.1
Host: graph.moozar.com
Content-Type: application/x-www-form-urlencoded
grant_type=access_token&
client_id={CLIENT_ID}&
client_secret={CLIENT_SECRET}&
redirect_uri={REDIRECT_URI}&
access_token={ACCESS_TOKEN}
$Moozar->getAccessToken();
Moozar.getAccessToken(function(token) {
//handle the token...
});
This will return:
{
"expired_in": {VALUE}
}
or, if the access_token is unavailable or expired:
{
"error": token expired
}
The refresh_token has to be saved, as it grants you to ask as many access_token as you need, unless the user disallow your app.
Refresh token(s)
If your access_token has expired, you'll need to ask for a new one.
This needs a POST request to http://graph.moozar.com/ including your refresh_token and these parameters :
POST /firewall/token HTTP/1.1
Host: graph.moozar.com
Content-Type: application/x-www-form-urlencoded
grant_type=refresh_token&
client_id={CLIENT_ID}&
client_secret={CLIENT_SECRET}&
redirect_uri={REDIRECT_URI}&
refresh_token={REFRESH_TOKEN}
Moozar.refreshToken(function(token) {
//handle the token...
});
This will return:
{
"access_token": {NEW_ACCESS_TOKEN}
"expired_in": 3600
}
Permissions
| Scope |
Description |
| received_reward | Enable your app to get the rewards a user received. |
| given_reward | Enable your app to get the rewards a user did. |
| manage_playlist | Enable your app to to manage the playlists of a user. |
| manage_title | Enable your app to to manage the titles of a user. |
| profile_info | Enable your app to get the user email, name and first name. |
RETRIEVE DATAS
The Moozar API gives you access to Moozar resources like artists, titles, users ...
These resources can be accessed and manipulated using the HTTP method GET.
To access public resources you just have to pass a client_id parameter.
To access private ressources of a Moozar user, they must first authenticate your app using the method we've discuss in the previous section.
If the user is authorized, user_id and artist_id can be replaced by "me" when building the request.
/search/{keyword}
This method provides you a way to find specifics datas you need from an artist, title or user name.
http://graph.moozar.com/search/{KEYWORD}/{CLIENT_ID}
$Moozar->search({KEYWORD}); OR $Moozar->api('search/{KEYWORD}');
Moozar.api('search/{KEYWORD}');
| type |
name |
id |
| artist | {NAME_ARTIST} | {ARTIST_ID} |
| title | {NAME_TITLE} | {TILE_ID} |
/user/{user_id}
http://graph.moozar.com/user/{USER_ID}/{YOUR_CLIENT_ID}/{YOUR_ACCESS_TOKEN}
$Moozar->getUser({USER_ID}); OR $Moozar->api('user/{USER_ID}');
Moozar.api('user/{USER_ID}');
Response properties
| Key |
Value |
Scope |
| user | { Object } | None |
| Artist (if any) | { Object } | None |
User properties
| Key | Value | Scope |
| id | Value of the user_id | None |
| first_name | First name of the user | PROFILE_INFO |
| last_name | Last name of the user | PROFILE_INFO |
| email | Mail adress of the user | PROFILE_INFO |
| image | Image of the user | PROFILE_INFO |
| nb_playlists | Number of the playlists the user did. | None |
| link | Link to the user page | None |
Artist properties
| Key | Value | Scope |
| id | Value of the artist_id | None |
| name | name of the artist | None |
| link | Link to the artist page | None |
/user/{user_id}/playlists
http://graph.moozar.com/user/{USER_ID}/playlists/{YOUR_CLIENT_ID}/{YOUR_ACCESS_TOKEN}
$Moozar->getPlaylists({USER_ID}); OR $Moozar->api('user/{USER_ID}/playlists');
Moozar.api('user/{USER_ID}/playlists');
Playlists properties
| Key | Value | Scope |
| id | Value of the playlist_id. | None |
| name | Name of the playlist. | None |
| nb_titles | Number of tracks in this playlist. | None |
| link | Link to the user page. | None |
| nb_share | Number of share. | None |
| created_at | Date of creation of this playlist. | None |
| user_id | user_id of the owner of this playlist. | None |
/user/{user_id}/rewards
http://graph.moozar.com/user/{USER_ID}/rewards/{YOUR_CLIENT_ID}/{YOUR_ACCESS_TOKEN}
$Moozar->getRewards({USER_ID}); OR $Moozar->api('user/{USER_ID}/rewards');
Moozar.api('user/{USER_ID}/rewards');
Rewards Properties
| Type | Scope | Type | Scope |
| given | received_reward | received | given_reward |
Given properties
| Key | Value |
| id | Value of the reward_id |
Received properties
| Key | Value |
| id | Value of the reward_id |
/artist/{artist_id}
http://graph.moozar.com/artist/{ARTIST_ID}/{YOUR_CLIENT_ID}/{YOUR_ACCESS_TOKEN}
$Moozar->getArtist({ARTIST_ID}); OR $Moozar->api('artist/{ARTIST_ID}');
Moozar.api('artist/{ARTIST_ID}');
Response properties
| Key | Value | Scope |
| artist | {Artist Object} (check the properties below) | None |
| user | {User Object} (check the properties below) | None |
Artist properties
| Key | Value | Scope |
| id | Value of the artist_id. | None |
| name | Name of the artist. | None |
| website | Website of the artist. | None |
| link | Link to the Moozar artist page. | None |
| image | Image of the artist. | None |
| facebook | Facebook of the artist (if any). | None |
| twitter | Twitter of the artist (if any). | None |
| youtube | Youtube of the artist (if any). | None |
| soundcloud | Soundcloud of the artist (if any). | None |
| itune | Itune of the artist (if any). | None |
| amazon | Amazon of the artist (if any). | None |
| myspace | Myspace of the artist (if any). | None |
| beatport | Beatport of the artist (if any). | None |
| dailymotion | Dailymotion of the artist (if any). | None |
| vimeo | Vimeo of the artist (if any). | None |
User properties
| Key | Value | Scope |
| id | Value of the user_id. | None |
/artist/{artist_id}/titles
http://graph.moozar.com/artist/{ARTIST_ID}/titles/{YOUR_CLIENT_ID}/{YOUR_ACCESS_TOKEN}
$Moozar->getTitles({ARTIST_ID}); OR $Moozar->api('artist/{ARTIST_ID}/titles');
Moozar.api('artist/{ARTIST_ID}/titles');
Titles properties (Array)
| Key | Value | Scope |
| id | Value of the tile_id. | None |
| name | Name of the title. | None |
| created_at | Date the title has been imported on Moozar. | None |
| artist_id | artist_id of the owner of this title. | None |
/artist/{artist_id}/albums
http://graph.moozar.com/artist/{ARTIST_ID}/albums/{YOUR_CLIENT_ID}/{YOUR_ACCESS_TOKEN}
$Moozar->getAlbums({ARTIST_ID}); OR $Moozar->api('artist/{ARTIST_ID}/albums');
Moozar.api('artist/{ARTIST_ID}/albums');
/title/{title_id}
http://graph.moozar.com/title/{TITLE_ID}/{YOUR_CLIENT_ID}/{YOUR_ACCESS_TOKEN}
$Moozar->getTitle({TITLE_ID}); OR $Moozar->api('title/{TITLE_ID}');
Moozar.api('title/{TITLE_ID}');
Title properties (Object)
| Key | Value | Scope |
| id | Value of the tile_id. | None |
| name | Name of the title. | None |
| link | Link to the title. | None |
| reward_link | The reward link. | None |
| nb_share | Number of share. | None |
| nb_play | Number of view on Moozar. | None |
| created_at | Date the title has been imported on Moozar. | None |
| artist_id | artist_id of the owner of this title. | None |
/title/{title_id}/rewards
http://graph.moozar.com/title/{TITLE_ID}/{YOUR_CLIENT_ID}/{YOUR_ACCESS_TOKEN}
$Moozar->getTitleRewards({TITLE_ID}); OR $Moozar->api('title/{TITLE_ID}/rewards');
Moozar.api('title/{TITLE_ID}/rewards');
Rewards properties (Array)
| Key | Value | Scope |
| id | Value of the reward_id. | None |
| amount | Amount of the reward. | reward_received, reward_given |
| created_at | Date the reward has been made. | None |
/album/{album_id}
http://graph.moozar.com/album/{ALBUM_ID}/{YOUR_CLIENT_ID}/{YOUR_ACCESS_TOKEN}
$Moozar->getAlbum({ALBUM_ID}); OR $Moozar->api('album/{ALBUM_ID}');
Moozar.api('album/{ALBUM_ID}');
/playlist/{playlist_id}
http://graph.moozar.com/playlist/{playlist_id}/{YOUR_CLIENT_ID}/{YOUR_ACCESS_TOKEN}
$Moozar->getPlaylist({PLAYLIST_ID}); OR $Moozar->api('playlist/{PLAYLIST_ID}');
Moozar.api('playlist/{PLAYLIST_ID}');
Playlist properties (Object)
| Key | Value | Scope |
| id | Value of the playlist_id. | None |
| name | Name of the playlist. | None |
| nb_titles | Number of tracks in this playlist. | None |
| link | Link to the user page. | None |
| nb_share | Number of share. | None |
| titles | Array of titles | None |
| created_at | Date of creation of this playlist. | None |
| user_id | user_id of the owner of this playlist. | None |
Title properties (Object)
| Key | Value | Scope |
| id | Value of the tile_id. | None |
| name | Name of the title. | None |
| link | Link to the title. | None |
| reward_link | The reward link. | None |
| nb_share | Number of share. | None |
| nb_play | Number of view on Moozar. | None |
| created_at | Date the title has been imported on Moozar. | None |
| artist_id | artist_id of the owner of this title. | None |
/reward/{reward_id}
http://graph.moozar.com/title/{TITLE_ID}/{YOUR_CLIENT_ID}/{YOUR_ACCESS_TOKEN}
$Moozar->getTitle({TITLE_ID}); OR $Moozar->api('title/{TITLE_ID}');
Moozar.api('title/{TITLE_ID}');
Reward properties (Object)
| Key | Value | Scope |
| id | Value of the reward_id. | None |
| giver_id | user_id of the giver. | given_reward |
| receiver_id | user_id of the receiver. | received_reward |
| amount | Amount of the reward. | given_reward, received_reward |
| tile_name | Name of the title rewarded. | None |
| tite_id | id of the title rewarded. | None |
| created_at | Date the reward has been made. | None |