https://github.com/echonest/php-echonest-api
PHP classes for the Echo Nest API
https://github.com/echonest/php-echonest-api
Last synced: 4 days ago
JSON representation
PHP classes for the Echo Nest API
- Host: GitHub
- URL: https://github.com/echonest/php-echonest-api
- Owner: echonest
- License: mit
- Fork: true (bshaffer/php-echonest-api)
- Created: 2011-04-04T15:11:37.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2011-04-04T16:17:09.000Z (about 15 years ago)
- Last Synced: 2024-03-26T01:36:38.751Z (about 2 years ago)
- Language: PHP
- Homepage:
- Size: 171 KB
- Stars: 37
- Watchers: 16
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-github-projects - php-echonest-api - PHP classes for the Echo Nest API ⭐37 `PHP` (📦 Legacy & Inactive Projects)
README
# PHP Echo Nest API
A simple, Object Oriented API wrapper for the EchoNest Api written with PHP5.
This library is modeled after the [php-github-api](https://github.com/ornicar/php-github-api) library built by [ornicar](https://github.com/ornicar)
Uses [EchoNest API v4](http://developer.echonest.com/docs/v4/).
Requires
* PHP 5.2 or 5.3.
* [php curl](http://php.net/manual/en/book.curl.php) but it is possible to write another transport layer..
If the method you need does not exist yet, dont hesitate to request it with an [issue](http://github.com/bshaffer/php-echonest-api/issues)!
## Autoload
The first step to use php-echonest-api is to register its autoloader:
require_once '/path/to/lib/EchoNest/Autoloader.php';
EchoNest_Autoloader::register();
Replace the `/path/to/lib/` path with the path you used for php-echonest-api installation.
> php-echonest-api follows the PEAR convention names for its classes, which means you can easily integrate php-echonest-api classes loading in your own autoloader.
## Instanciate a new EchoNest Client
$echonest = new EchoNest_Client();
From this object you can now access all of the different EchoNest APIs (listed below)
### Authenticate a user
Authenticate using your EchoNest API Key. You can obtain one at EchoNest by [Registering an Account](http://developer.echonest.com/account/register)
$echonest->authenticate($apiKey);
### Deauthenticate a user
Cancels authentication.
$echonest->deAuthenticate();
Next requests will not be authenticated
## Artists
For searching artists, getting artist information and music.
Wraps [EchoNest Artist API](http://developer.echonest.com/docs/v4/artist.html).
$artistApi = $echonest->getArtistApi();
### Search for artists by name
$results = $echonest->getArtistApi()->search(array('name' => 'Radiohead'));
print_r($results);
Array
(
[status] => Array
(
[version] => 4.2
[code] => 0
[message] => Success
)
[artists] => Array
(
[0] => Array
(
[name] => Radiohead
[id] => ARH6W4X1187B99274F
)
)
)
Returns an array of results as described in [http://developer.echonest.com/docs/v4/artist.html#search](http://developer.echonest.com/docs/v4/artist.html#search)
### Get information about an artist
$bios = $echonest->getArtistApi()->setName('Radiohead')->getBiographies();
Once you set an artists name or id on an artist API, the API will remember that artist and use them for future function calls
$artistApi = $echonest->getArtistApi();
$artistApi->setName('Radiohead');
$bios = $artistApi->getBiographies();
$audio = $artistApi->getAudio();
$images = $artistApi->getImages();
Each function comes with a variety of options. Please view the documentation in this project or on http://echonest.com to see all the options available
## Songs
Api calls for getting data about songs.
Wraps [EchoNest Song API](http://developer.echonest.com/docs/v4/song.html).
$songApi = $echonest->getSongApi();
Please view the documentation in this project or on http://echonest.com to see all the options available
## Playlists
Api calls for generating playlists.
Wraps [EchoNest Playlist API](http://developer.echonest.com/docs/v4/playlist.html).
$playlistApi = $echonest->getPlaylistApi();
Please view the documentation in this project or on http://echonest.com to see all the options available
## Catalogs
API calls for managing personal catalogs.
Wraps [EchoNest Catalog API](http://developer.echonest.com/docs/v4/catalog.html).
$catalogApi = $echonest->getCatalogApi();
Please view the documentation in this project or on http://echonest.com to see all the options available
## Tracks
Methods for analyzing or getting info about tracks.
Wraps [EchoNest Track API](http://developer.echonest.com/docs/v4/track.html).
$trackApi = $echonest->getTrackApi();
Please view the documentation in this project or on http://echonest.com to see all the options available
# To Do
Better documentation and test coverage will be coming soon