Search code examples
magento2magento-rest-api

Magento 2 - Where to find the complete REST API documentation


It seems like the official Magento 2 REST API Documentation is not complete.

I found this code in a application of one of our ex colleagues:

protected function addItemToCart($cartId, $cartItem)
{
    return $this->client->request('POST', "carts/{$cartId}/items", [
        'json' => [
            'cartItem' => $cartItem,
        ],
    ]);
}

But I can't find any documenation for carts/{$cartId}/items.

The nearest I can find is: /V1/guest-carts/{cartId}/items

Where can I find the documentation for carts/{$cartId}/items?


Solution

  • There isn't a POST method available on the carts/{$cartId}/items route.


    So there's probably something else going on, could be one of these:

    • Actually you're using POST /V1/carts/{quoteId}/items
    • Your ex-colleagues extended the default API so the POST on carts/{$cartId}/items is a custom endpoint
    • You are using a very old Magento version in which this was available.

    Consider using the ReDoc Documentation page.