Order and return data from Shopware 6 API

Hi all,

Using the admin order API we are able to get basic order data such as order ids, net sales, totals sales, tax & shipping.

But we’re missing crucial information that we want to get with our orders:

  • Coupon code (if used)
  • Coupon discount (if coupon used)
  • Items (which items are sold in the order based on order ID)

Which endpoints do we need to connect to, to get the above information?

Also is there an endpoint like ‚order‘ to get return information, such as return amount, items returned with dates.

Would like to hear from the community!

Thanks in advance.

You can get all data from api/serach/order for example and you have to include all assocications in your json, like associations.lineItems.associations.product

Thanks, that helped me towards the right direction! I was not aware of the search API and associations.

For others running into this issue, here’s my request to the Shopware 6 API using Guzzle & PHP:

$client = new GuzzleHttp\Client();

$response = $client->request('POST', '/api/search/order', [
	'headers' => [
		'Authorization' => 'Bearer ' . $access_token,
		'Accept' => 'application/json'
	],
	'form_params' => [
		'associations' => [
			'billingAddress' => [
				'limit' => 1,
				'associations' => [
					'country' => [
						'limit' => 1 ],
				],
			],
			'lineItems' => [
				'associations' => [
					'product' => [
						'limit' => 100,
					],
				],
			]
		],
		
		'includes' => [
			'order' => ['orderDateTime', 'orderNumber', 'lineItems', 'billingAddress', 'price', 'shippingCosts'],
			'order_line_item' => ['label', 'totalPrice'],
			'order_address' => ['country'],
			'country' => ['name'],
			'cart_price' => ['netPrice', 'totalPrice', 'calculatedTaxes'],
			'cart_tax_calculated' => ['tax'],
			'calculated_price' => ['totalPrice'],
		]
	]]);

$response->getBody()

thx man for posting this!