Find a product by name, to reuse it
inventory.product.search
GET/api/v1/households/{household_id}/queries/inventory.product.search
- Query
- Rigel runs it
Products whose name contains the text, ignoring case and a plural "s": exact matches first, then names starting with it, then the rest, each with its category, staple flag and how many items we have. Use it before creating a product so the household keeps one "black beans", not three.
Parameters#
| Field | Description |
|---|---|
household_idpathstringrequired | The household's ID. |
textquerystringrequired | Part of the name to look for. |
limitqueryintegeroptional | How many to return, 1–50. Defaults to 10. |
Response#
200 The answer.
| Field | Description |
|---|---|
itemsarray of objectsrequired | |
items[].idstringrequired | A product ID, such as prd_01JC0000000000000000000000. |
items[].namestringrequired | No description. |
items[].categorystring or nullrequired | Its category's name, or null. |
items[].is_staplebooleanrequired | No description. |
items[].is_trackedbooleanrequired | No description. |
items[].default_location_idstring or nullrequired | Where it usually goes. |
items[].item_countintegerrequired | How many inventory items of it we have. |
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.
Search products for flour
curl 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/queries/inventory.product.search?text=flour' \
-H "Cookie: rigel_session=$RIGEL_SESSION"const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/queries/inventory.product.search?text=flour", {
headers: {
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
});
const data = await response.json();GET /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/queries/inventory.product.search?text=flour HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CSBBH62CFTHETSGKN841
{
"items": [
{
"id": "prd_01M6V9CSAG72MC7ERJ4GCZ0X7A",
"name": "Flour",
"category": "Baking",
"is_staple": true,
"is_tracked": true,
"default_location_id": "loc_01M6V9CSA910340EZNX67RFMV0",
"item_count": 1
}
]
}For Rigel#
Rigel's tool for this query is inventory_product_search. Rigel runs this on its own, then says what it did. The agent guide has the rest.