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.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;
Moozar.refreshToken(function(token) {
  //handle the token...
});

This will return:

{
  "access_token": {NEW_ACCESS_TOKEN}
  "expired_in": 3600
}

Permissions

Scope Description
received_rewardEnable your app to get the rewards a user received.
given_rewardEnable your app to get the rewards a user did.
manage_playlistEnable your app to to manage the playlists of a user.
manage_titleEnable your app to to manage the titles of a user.
profile_infoEnable 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
KeyValueScope
idValue of the user_idNone
first_nameFirst name of the userPROFILE_INFO
last_nameLast name of the userPROFILE_INFO
emailMail adress of the userPROFILE_INFO
imageImage of the userPROFILE_INFO
nb_playlistsNumber of the playlists the user did.None
linkLink to the user pageNone
Artist properties
KeyValueScope
idValue of the artist_idNone
namename of the artistNone
linkLink to the artist pageNone

/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
KeyValueScope
idValue of the playlist_id.None
nameName of the playlist.None
nb_titlesNumber of tracks in this playlist.None
linkLink to the user page.None
nb_shareNumber of share.None
created_atDate of creation of this playlist.None
user_iduser_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
TypeScopeTypeScope
givenreceived_rewardreceivedgiven_reward
Given properties
KeyValue
idValue of the reward_id
Received properties
KeyValue
idValue 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
KeyValueScope
artist{Artist Object} (check the properties below)None
user{User Object} (check the properties below)None
Artist properties
KeyValueScope
idValue of the artist_id.None
nameName of the artist.None
websiteWebsite of the artist.None
linkLink to the Moozar artist page.None
imageImage of the artist.None
facebookFacebook of the artist (if any).None
twitterTwitter of the artist (if any).None
youtubeYoutube of the artist (if any).None
soundcloudSoundcloud of the artist (if any).None
ituneItune of the artist (if any).None
amazonAmazon of the artist (if any).None
myspaceMyspace of the artist (if any).None
beatportBeatport of the artist (if any).None
dailymotionDailymotion of the artist (if any).None
vimeoVimeo of the artist (if any).None
User properties
KeyValueScope
idValue 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)
KeyValueScope
idValue of the tile_id.None
nameName of the title.None
created_atDate the title has been imported on Moozar.None
artist_idartist_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)
KeyValueScope
idValue of the tile_id.None
nameName of the title.None
linkLink to the title.None
reward_linkThe reward link.None
nb_shareNumber of share.None
nb_playNumber of view on Moozar.None
created_atDate the title has been imported on Moozar.None
artist_idartist_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)
KeyValueScope
idValue of the reward_id.None
amountAmount of the reward.reward_received, reward_given
created_atDate 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)
KeyValueScope
idValue of the playlist_id.None
nameName of the playlist.None
nb_titlesNumber of tracks in this playlist.None
linkLink to the user page.None
nb_shareNumber of share.None
titlesArray of titlesNone
created_atDate of creation of this playlist.None
user_iduser_id of the owner of this playlist.None
Title properties (Object)
KeyValueScope
idValue of the tile_id.None
nameName of the title.None
linkLink to the title.None
reward_linkThe reward link.None
nb_shareNumber of share.None
nb_playNumber of view on Moozar.None
created_atDate the title has been imported on Moozar.None
artist_idartist_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)
KeyValueScope
idValue of the reward_id.None
giver_iduser_id of the giver.given_reward
receiver_iduser_id of the receiver.received_reward
amountAmount of the reward.given_reward, received_reward
tile_nameName of the title rewarded.None
tite_idid of the title rewarded.None
created_atDate the reward has been made.None