Unofficial PHP API Client for PS in foodservice Web API (PS-API)
This library helps you interact with the PS-API, version 6.
🌍 PS in foodservice | https://psinfoodservice.nl/ |
📕 API documentation | https://webapi.psinfoodservice.com/V6/prod/Home/EN |
📦 Composer package | softwarepunt/psinfoodservice-api-client |
⚠ Heads up - Limited scope: this library currently only supports retrieving product information. PRs for other API features are welcome. :)
- PHP 8.2+
- with extensions: curl, simplexml
- Composer
Use Composer to add the package as a dependency to your project:
composer require softwarepunt/psinfoodservice-api-client
To begin, include the Client and set your credentials and options.
🔒 If you do not have credentials yet, contact PS in foodservice to request them first.
<?php
use SoftwarePunt\PSAPI\Client;
require_once "vendor/autoload.php";
$client = new Client();
$client->setUsername("[email protected]");
$client->setPassword("************");
$client->setTimeout(30);
All implemented API routes will match the URL structure, for example:
// Example of structure - the code route for "api/Product/Search" call:
$client->product()->search();
You can search for a product by providing parameters. You must select one "product set" at minimum; for example: all public products.
You will typically use this to find a specific product, for example:
use SoftwarePunt\PSAPI\Models\Params\ProductSearchParams;
$searchParams = new ProductSearchParams();
$searchParams->ShowAllProductSet = true;
$searchParams->ShowSubscribedProductSet = true; // must be set to explicitly include private data
$searchParams->FilterOnEan = "1213456789125";
$products = $client->product()->search($searchParams);
$product = $products->product[0];
echo $product->summary->name; // PS Citroensnoepje 20g
☝ The objects returned by this library are based on the API's actual XML response structure. They are fully type-hinted and have docblocks where available.
This project contains a tool that can generate or update entities from the XSD file provided by PS. All classes in src/Models/Entities
are generated using this tool. You can use it as follows:
To use it, manually run the CLI script from the project directory:
php cli/xsdgen.php path/to/PS_XSD.xsd
You can download the latest XSD via the documentation page: https://webapi.psinfoodservice.com/V6/prod/Documentation/Xsd