Where and when an inventory item was bought
shopping.purchase.for_item
GET/api/v1/households/{household_id}/queries/shopping.purchase.for_item
- Query
- Rigel runs it
The trip that bought this inventory item, when shopping put it away: the store, the date and, if a receipt was read, the price. Null when the item didn't come from a recorded trip.
Parameters#
| Field | Description |
|---|---|
household_idpathstringrequired | The household's ID. |
item_idquerystringrequired | The inventory item. |
Response#
200 The answer.
| Field | Description |
|---|---|
purchaseobject or nullrequired | The purchase, or null. |
purchase.trip_idstringrequired | A shopping trip ID, such as trp_01JC0000000000000000000000. |
purchase.trip_item_idstringrequired | A shopping trip item ID, such as tri_01JC0000000000000000000000. |
purchase.storeobject or nullrequired | Where it was bought, or null when the trip has no store. |
purchase.store.idstringrequired | A store ID, such as sto_01JC0000000000000000000000. |
purchase.store.namestringrequired | The store's name. |
purchase.shopped_onstring (date)required | The day it was bought. |
purchase.amountstring or nullrequired | How much was bought, such as "2 lb", or null when not recorded. |
purchase.price_minorinteger or nullrequired | The line's price in minor units, when a receipt said. |
purchase.currencystring or nullrequired | The price's currency, when there is a price. |
Errors#
Every error has the same envelope: error.code, error.message, error.details, error.recovery and error.request_id.
| Status | Code | When |
|---|---|---|
400 | validation_failed | A field is missing, misspelled or out of range. details.fields lists each problem. |
401 | unauthenticated | The request has no valid session. |
404 | not_found | The household doesn't exist, or you aren't a member of it. |
Examples#
These are real. Each was recorded from a sample household, the Okafors, running through the whole API when this site was built.
Where was this bought
The trip that bought an inventory item, when shopping put it away.
curl 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/queries/shopping.purchase.for_item?item_id=inv_01M6V9CSAWTFE7ARBQF4CXQ31Q' \
-H "Cookie: rigel_session=$RIGEL_SESSION"const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/queries/shopping.purchase.for_item?item_id=inv_01M6V9CSAWTFE7ARBQF4CXQ31Q", {
headers: {
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
});
const data = await response.json();GET /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/queries/shopping.purchase.for_item?item_id=inv_01M6V9CSAWTFE7ARBQF4CXQ31Q HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CT9MA89CW26H53D6F6FE
{
"purchase": {
"trip_id": "trp_01M6V9CT8JBJVJK865ZH4D2ZZD",
"trip_item_id": "tri_01M6V9CT8J45W20665WG2VHYPE",
"store": {
"id": "sto_01M6V9CT6QQBTTA6DBQXS60NCD",
"name": "Greenway Market"
},
"shopped_on": "2026-11-07",
"amount": "2 gallons",
"price_minor": 778,
"currency": "USD"
}
}Ask about an item that wasn't bought on a trip
The answer is null.
curl 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/queries/shopping.purchase.for_item?item_id=inv_01M6V9CSAJYYMNC0TXJX8NRN8T' \
-H "Cookie: rigel_session=$RIGEL_SESSION"const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/queries/shopping.purchase.for_item?item_id=inv_01M6V9CSAJYYMNC0TXJX8NRN8T", {
headers: {
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
});
const data = await response.json();GET /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/queries/shopping.purchase.for_item?item_id=inv_01M6V9CSAJYYMNC0TXJX8NRN8T HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CT9P229E04MA5XZ88TEW
{
"purchase": null
}For Rigel#
Rigel's tool for this query is shopping_purchase_for_item. Rigel runs this on its own, then says what it did. The agent guide has the rest.