Page 1 of 1

Rest APIs for fetch the Basket

Posted: 30 Nov 2019, 07:23
by traiyani75
Hello,

We have questions related to baskets operations.
First, Here we can add products to the basket without user login using the following API
URL: { basket_url }?id=abc123&related=product

Request : {"data":[{"attributes":{"product.id": 18,"quantity": 1}}]}
----
Now, we need to fetch this basket product again, We checked the documentation that we can use URL which coming on OPTIONS request (response.meta.resources['basket']). But how do we get data for the user who just added products in the basket? Do we need to pass any token or id with the URL?

Re: Rest APIs for fetch the Basket

Posted: 30 Nov 2019, 18:54
by aimeos
You get the basket content back if you add something to the basket and you can always fetch the basket using the basket endpoint listed in the OPTIONS response. The basket content is session based which means you usually need to pass the session cookie along with your request.

Re: Rest APIs for fetch the Basket

Posted: 02 Dec 2019, 05:28
by traiyani75
Thanks for the answer.
This session will generate for login user if I am not wrong, but we are allowing a user to add products into the basket without login too. Then how do we handle sessions for those users?

And how to get session tokens in rest api calls. ?

Re: Rest APIs for fetch the Basket

Posted: 02 Dec 2019, 05:46
by traiyani75
And we are using this on the mobile side. How do we use the session ?

Re: Rest APIs for fetch the Basket

Posted: 03 Dec 2019, 08:55
by aimeos
As you are using Laravel as framework for Aimeos, you can use the standard Laravel means for session and authentication, e.g.
https://laravel.com/docs/6.x/api-authentication