jolitagrazyte / discogs-api
A simple Discogs Api wrapper using Guzzle7.
Requires
- php: ^7.4|^8.1|^8.2
- ext-json: *
- guzzlehttp/guzzle: ^7.8
- illuminate/support: ^9.28|^10.0|^11.0
Requires (Dev)
- mockery/mockery: ^1.4.4
- phpunit/phpunit: ^9.5|^10.5|^11.0
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2024-11-04 10:48:31 UTC
README
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.
Installation
You can install the package via composer:
composer require jolitagrazyte/discogs-api
Usage
Endpoints with no authentication required
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');
Endpoints where authentication is required
For the endpoints, where token is required, you must add your discogs-token.
You can obtain it at https://www.discogs.com/settings/developers.
Orders
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');
Search
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);
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email hello@jolitagrazyte.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.