This package makes it easy to communicate with discogs-api. It uses Guzzle 7 and is very simple to install and to use.
You can use it with any PHP framework or just simply in your naked PHP application.
However, if you want to use it in Laravel framework, I'd suggest to also install jolitagrazyte/laravel-discogs package, which provides a facade for even an easier way to play with it.
You can install the package via composer:
composer require jolitagrazyte/discogs-api
For the endpoints, where token is not required, first argument can be easily left empty.
$discogs = new DiscogsApi();
//get artist with id 1
$artist = $discogs->artist('1');
//get releases of the artist with id 1
$artistReleases = $discogs->artistReleases('1');
//get label with id 1
$label = $discogs->label('1');
//get releases of the label with id 1
$labelReleases = $discogs->labelReleases('1');
//get release with id 1
$releases = $discogs->releases('1');
//get master release with id 1
$masterRelease = $discogs->masterRelease('1');
For the endpoints, where token is required, you must add your discogs-token.
You can obtain it at https://www.discogs.com/settings/developers.
To get your orders, you can use getMyOrders()-method.
Orders list comes paginated with a default - 50 orders per page, but it can be changed.
If you need, you can add some optional parameters: page
, perPage
(with a max of 100), order status as status
, sort
and sortOrder
.
If you need more information about the parameters you can read about it at https://www.discogs.com/developers.
$discogs = new DiscogsApi('discogs-token', 'app-name');
//get orders
$orders = $discogs->getMyOrders();
/**
* get orders with parameters:
* in this example page = 3, perPage = 25, status = shipped, sort = created, sortOrder = desc
*/
$ordersWithOptions = $discogs->getMyOrders(3, 25, "shipped", "created", "desc");
For getting one specific order by id:
$discogs = new DiscogsApi('discogs-token', 'app-name');
//get order with id
$order = $discogs->orderWithId('123');
It is also possible to retrieve the messages of an order:
$discogs = new DiscogsApi('discogs-token', 'app-name');
//get messages of an order with id
$ordersMessages = $discogs->orderMessages('123');
For changing the status of the order or adding the shipping to the order.
$discogs = new DiscogsApi('discogs-token', 'app-name');
//change order status to 'Shipped'
$orders = $discogs->changeOrderStatus('123', 'Shipped');
//add shipping to an order with id
$order = $discogs->addShipping('123', '12.60');
If you want to add some extra search parameters you can do it by first creating a SearchParameters object and then chaining as many options as you want.
$discogs = new DiscogsApi('discogs-token', 'app-name');
// create a SearchParameters object and chain some search paramater
$searchParameters = SearchParameters::make()->format('LP')->year('1996');
//do a search request with a query = 'MoWax' and passing the SearchParameters object
$searchResult = $discogs->search('MoWax', $searchParameters);
Please see CHANGELOG for more information what has changed recently.
$ composer test
Please see CONTRIBUTING for details.
If you discover any security related issues, please email hello@jolitagrazyte.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.