OAuth API Request to Beatport API
PHP
Switch branches/tags
Nothing to show
Latest commit 9c3ebed Aug 26, 2014 @fedegiust bug fixes
Permalink
Failed to load latest commit information.
.gitignore
README.md Include Readme.md Feb 7, 2014
beatport_api.php bug fixes Aug 26, 2014
beatport_callback.php Generate JSON feed from Beatport API Feb 2, 2014
config.tmp.php Update, code comments and tidy up Feb 7, 2014
error_log Clean error log Feb 3, 2014
log_calls.php Update, code comments and tidy up Feb 7, 2014

README.md

Beatport API OAuth

With this PHP script you will be able to make api calls to the new Beatport API using OAuth and generate a JSON feed.

So for example you can use this on your server and using jQuery ajax to get a JSON object and do anything you need with it on your server.

Requirements

Install

Once you've installed PHP OAuth, upload this script to your server.

Edit config.tmp.php and fill in the constant declarations with the corresponding values

<?php
/**
* DB Log Settings
*/

/** MySQL database */
define('DB_NAME', '');

/** MySQL database username */
define('DB_USER', '');

/** MySQL database password */
define('DB_PASSWORD', '');

/** MySQL hostname for example: localhost */
define('DB_HOST', '');

/**
* API Call OAuth Settings
*/

/** Website URL where beatport_api_callback.php is sitting  */
define('WEBSITE', '');

// Beatport API Consumer Key
define('CONSUMERKEY', '');

// Beatport API Secret Key
define('SECRETKEY', '');

// Beatport Login Details
define('BEATPORTLOGIN', '');

define('BEATPORTPASSWORD', '');

?>

Rename config.tmp.php to config.php

There are a couple of query string parameters that you can use to make different calls:

Parameter Description
facets facets to be used in the api call (for example: performerName:Richie+Hawtin)
sortBy how do you want the data to be sorted
perPage how many results you want to get per page
id track id (this can be used if no facets is being used)
url path to be concatenated to the call if you want tracks, release, etc
check Beatport API Documentation for more details)

You can start making calls to a url like this:

www.yourwebsite.com/beatportapi/beatport_api.php?facets=performerName:Richie+Hawtin&sortBy=publishDate%20desc&perPage=10&url=tracks

This will generate the api call to a URL like this:

https://oauth-api.beatport.com/catalog/3/tracks?facets=artistName%3ARichie+Hawtin&perPage=10&sortBy=publishDate+DESC

Which will get you a JSON object like this:

{
  "metadata": {
    "host": "api.beatport.com",
    "path": "/catalog/tracks",
    "query": "facets%5B0%5D=artistName%3ARichie%2BHawtin&perPage=10&sortBy=publishDate+DESC",
    "page": 1,
    "perPage": 10,
    "count": 0,
    "totalPages": 0,
    "perPageOptions": [
      {
        "value": 50,
        "applyQuery": "facets%5B0%5D=artistName%3ARichie%2BHawtin&perPage=50&sortBy=publishDate+DESC"
      },
      {
        "value": 100,
        "applyQuery": "facets%5B0%5D=artistName%3ARichie%2BHawtin&perPage=100&sortBy=publishDate+DESC"
      },
      {
        "value": 150,
        "applyQuery": "facets%5B0%5D=artistName%3ARichie%2BHawtin&perPage=150&sortBy=publishDate+DESC"
      }
    ],
    "facets": {
      "fields": []
    },
    "appliedFacets": [],
    "dateFilters": [
      {
        "name": "today",
        "startDate": "2014-02-07",
        "endDate": "2014-02-07",
        "applyQuery": "facets%5B0%5D=artistName%3ARichie%2BHawtin&perPage=10&sortBy=publishDate+DESC&publishDateStart=2014-02-07&publishDateEnd=2014-02-07",
        "applied": false
      },
      {
        "name": "yesterday",
        "startDate": "2014-02-06",
        "endDate": "2014-02-07",
        "applyQuery": "facets%5B0%5D=artistName%3ARichie%2BHawtin&perPage=10&sortBy=publishDate+DESC&publishDateStart=2014-02-06&publishDateEnd=2014-02-07",
        "applied": false
      },
      {
        "name": "weekToDate",
        "startDate": "2014-01-31",
        "endDate": "2014-02-07",
        "applyQuery": "facets%5B0%5D=artistName%3ARichie%2BHawtin&perPage=10&sortBy=publishDate+DESC&publishDateStart=2014-01-31&publishDateEnd=2014-02-07",
        "applied": false
      },
      {
        "name": "monthToDate",
        "startDate": "2014-01-07",
        "endDate": "2014-02-07",
        "applyQuery": "facets%5B0%5D=artistName%3ARichie%2BHawtin&perPage=10&sortBy=publishDate+DESC&publishDateStart=2014-01-07&publishDateEnd=2014-02-07",
        "applied": false
      },
      {
        "name": "yearToDate",
        "startDate": "2013-02-07",
        "endDate": "2014-02-07",
        "applyQuery": "facets%5B0%5D=artistName%3ARichie%2BHawtin&perPage=10&sortBy=publishDate+DESC&publishDateStart=2013-02-07&publishDateEnd=2014-02-07",
        "applied": false
      },
      {
        "custom": true,
        "name": "customRange",
        "applied": false,
        "applyQuery": "facets%5B0%5D=artistName%3ARichie%2BHawtin&perPage=10&sortBy=publishDate+DESC"
      }
    ],
    "rangeFilters": {
      "bpm": {
        "custom": true,
        "rangeName": "bpm",
        "applied": false,
        "applyQuery": "facets%5B0%5D=artistName%3ARichie%2BHawtin&perPage=10&sortBy=publishDate+DESC"
      }
    },
    "spellcheck": null
  },
  "results": []
}

Feel free to extend this script to suit your needs.