Get basketv1.0.0 · JSON Schema
Returns the current basket and its item details.
1. Retrieve the Authenticated Shopper’s Enriched Basket
An authenticated shopper opens the cart page; Basket API loads the items from Redis and enriches each book’s name, price, and priceSale via Catalog API gRPC.
Payload details
id: Shopper/basket identifier (string | null).items: Array of enriched basket items (id,quantity,name,price, and nullablepriceSale).
Example response
{ "id": "01960a1b-2c3d-7e4f-8a9b-0c1d2e3f4a01", "items": [ { "id": "01960a1b-2c3d-7e4f-8a9b-0c1d2e3f4a10", "quantity": 1, "name": "The Left Hand of Darkness", "price": 18.99, "priceSale": 14.99 }, { "id": "01960a1b-2c3d-7e4f-8a9b-0c1d2e3f4a12", "quantity": 2, "name": "Dune", "price": 22.5, "priceSale": null } ]}Using this example
Returns 200 OK with the CustomerBasketDto JSON payload containing current catalog titles and prices.
using BookWorm.Chassis.Utilities.Configurations;using BookWorm.Constants.Aspire;using Refit;
public interface IBasketApiClient{ [Get("/api/v1/baskets")] Task<CustomerBasketResponse> GetBasketAsync(CancellationToken cancellationToken = default);}
public sealed record BasketItemResponse( string? Id, int Quantity, string? Name, double Price, double? PriceSale);
public sealed record CustomerBasketResponse(string? Id, IReadOnlyList<BasketItemResponse> Items);
// DI registration following BookWorm.Chassis Refit patternbuilder.Services .AddRefitGeneratedClient<IBasketApiClient>(settings, Services.Basket) .ConfigureHttpClient(client => client.BaseAddress = new($"https+http://{Services.Basket}")) .ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler { PooledConnectionLifetime = TimeSpan.FromMinutes(5) } );
// Typed invocationvar basket = await basketApiClient.GetBasketAsync(cancellationToken);import basketApiClient from "@workspace/api-client/basket/baskets";import useBasket from "@workspace/api-hooks/basket/useBasket";
// 1. Direct @workspace/api-client (Axios) callconst basket = await basketApiClient.get();
// 2. React / TanStack Query hook (@workspace/api-hooks)const { data: basketData, isLoading } = useBasket();1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "CustomerBasketDto",
4 "type": "object",
5 "required": ["id", "items"],
6 "properties": {
7 "id": {
8 "type": ["string", "null"]
9 },
10 "items": {
11 "type": "array",
12 "items": {
13 "type": "object",
14 "required": ["id", "quantity"],
15 "properties": {
16 "id": {
17 "type": ["string", "null"]
18 },
19 "quantity": {
20 "type": ["integer", "string"],
21 "format": "int32",
22 "pattern": "^-?(?:0|[1-9]\\d*)$"
23 },
24 "name": {
25 "type": ["string", "null"]
26 },
27 "price": {
28 "type": ["number", "string"],
29 "format": "double",
30 "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
31 "default": 0
32 },
33 "priceSale": {
34 "type": ["number", "string", "null"],
35 "format": "double",
36 "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$"
37 }
38 }
39 }
40 }
41 }
42}
43