With Insomnia REST Client

We will use Insomnia REST Client. (https://insomnia.rest)

sudo snap install insomnia



In Shopware admin (http://localhost:8000/admin) go to Settings -> System -> Integrations and Add integration.

Authentication

In Insomnia create new POST request:

POST: http://localhost:8000/api/oauth/token

JSON:
{
	"client_id": "SHOPWARE_ACCESS_KEY_ID",
	"client_secret": "SHOPWARE_SECRET_KEY",
	"grant_type": "client_credentials"
}

After running this request copy generated access_token.



Get Orders

GET: http://localhost:8000/api/v1/order



Get Order

GET: http://localhost:8000/api/v1/order?filter[order.id]=197DD5C23E584BADB19EBF15082A6286



Get Order Line Items

GET: http://localhost:8000/api/v1/order/197dd5c23e584badb19ebf15082a6286/line-items



https://docs.shopware.com/en/shopware-platform-dev-en/api/filter-search-limit?category=shopware-platform-dev-en/api




With Guzzle

Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services.

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

require('vendor/autoload.php');

$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'http://localhost:8000/api/oauth/token', [
    'json' => ["client_id" => "SHOPWARE_ACCESS_KEY_ID",
                "client_secret" => "SHOPWARE_SECRET_KEY",
                "grant_type" => "client_credentials"]
    ]);

    $body = json_decode($res->getBody());

    $guzzle = new GuzzleHttp\Client(['base_uri' => 'http://localhost:8000/']);
    $headers = [
        'Authorization' => 'Bearer ' . $body->access_token,        
        'Accept'        => 'application/json',
    ];
   
    $response = $client->request('GET', 'http://localhost:8000/api/v1/order/197dd5c23e584badb19ebf15082a6286/line-items',  [
        'headers' => $headers
    ]);

   echo $response->getBody();
?>