acendy / acendy-api-client
Acendy API Client
Requires
- php: >=8.2
- ext-fileinfo: *
Requires (Dev)
- guzzlehttp/guzzle: ^7.9.2
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.0.7
This package is auto-updated.
Last update: 2025-09-09 09:41:18 UTC
README
The Acendy API Client is a PHP library for interacting with the Acendy API.
For detailed API specifications, refer to the official documentation at http://mystoreapi.docs.apiary.io.
Getting Started
To use the Acendy API Client, you need an API token for authentication. Follow these steps:
- Obtain an API Token: Log in to https://auth.mystore.no/login and generate an API token. This token authenticates all requests made through the client.
- Review the API Docs: Visit http://mystoreapi.docs.apiary.io for comprehensive details on endpoints, authentication, and request/response formats.
- Set up the client: Use the token, your store's unique identifier, and the API base URL to initialize the client (see Installation and Usage Examples below).
Installation
composer require acendy/acendy-api-client
Using the library requires a PSR-18 compatible HTTP Client like GuzzleHTTP. If you don't have one, install Guzzle + PSR-7:
composer require guzzlehttp/guzzle guzzlehttp/psr7
Usage examples
Below are examples demonstrating how to use the Acendy API Client. These assume you have Guzzle installed.
Initializing the Client
Instantiate the AcendyApiClient with your API credentials and HTTP dependencies:
require_once __DIR__ . '/vendor/autoload.php'; use Acendy\Api\Client\AcendyApiClient; use GuzzleHttp\Client; use GuzzleHttp\Psr7\HttpFactory; $client = new AcendyApiClient( baseURL: 'https://api.mystore.no/', token: 'your-api-token', storeName: 'your-store-name', httpClient: new Client(), requestFactory: new HttpFactory(), streamFactory: new HttpFactory() );
Simple example: get all customers
Retrieve a list of all customers without additional parameters:
$customers = $client->customers()->getAllCustomers(); print_r($customers);
Simple example: get customer by id
Retrieve a single customer:
$customer = $client->customers()->getCustomerById('123456'); print_r($customer);
Basic example: get orders with pagination
Fetch orders with basic pagination using the QueryParameters class:
use Acendy\Api\Client\QueryParameters; $queryParams = new QueryParameters( pageNumber: 1, pageSize: 5 ); $paginatedOrders = $client->orders()->getAllOrders($queryParams); print_r($paginatedOrders);
Advanced example: Get orders with full query parameters
Perform a complex query on customers with filters, sorting, includes, and field selection:
use Acendy\Api\Client\QueryParameters; $queryParams = new QueryParameters( pageNumber: 1, pageSize: 50, filters: [ 'customer.id' => '123456', 'order-status.id' => '1', 'currency' => 'NOK' ], sort: ['-created_at'], include: ['customer', 'order-status', 'order-products'], fields: ['customer_address_name', 'currency', 'created_at'], ); $orders = $client->orders()->getAllOrders($queryParams); print_r($orders);