Dukan icon

Dukan

Interact with the Dukan API

State → Get Many States By Store

AI-generated

Summary

Retrieve multiple state records associated with a specific store by providing the store's MongoDB ObjectId and optional query parameters to control pagination, sorting, filtering, and returned fields.

Inputs

  • Store ID (required) — MongoDB ObjectId of the store whose states to list.
  • Page Number — The page number to retrieve, starting at 1 (default is 1).
  • Limit — Maximum number of state records to return (default is 50).
  • Sort — Field or space-separated fields to sort the returned states by (default is '-createdAt').
  • Populate Fields — Space-separated fields to populate in the returned documents.
  • Select Fields — Space-separated fields to explicitly select in the returned documents.
  • Offset — Number of records to skip from the start (default is 0).
  • Filter — JSON string representing a MongoDB filter query object to filter the results.
  • Force Custom Auth Header — Whether to use a custom API key instead of credentials configured in the node (default is false).
  • Custom API Key — Custom API key to use when Force Custom Auth Header is enabled.
  • Force Custom Base URL — Whether to use a custom base URL instead of the one from credentials (default is false).
  • Custom Base URL — Custom base URL for API requests when Force Custom Base URL is enabled (without the '/v1/external' suffix).
  • Request Options — Additional options for the HTTP request such as batching, proxy, timeout, and SSL certificate handling.

Output shape

a list of state objects matching the store filter, each including fields as specified by the select and populate parameters

The response supports pagination via 'page', 'limit', and 'offset' parameters. The filter parameter must be a valid MongoDB query in JSON string format. Sorting can be applied to one or multiple fields. If 'Force Custom Auth Header' or 'Force Custom Base URL' are enabled, the respective custom API key or base URL will override the credentials' defaults for this request.

Examples

Example 1: Retrieve the first 20 states for a given store ID, sorting by name ascending, selecting only the 'name' and 'code' fields.

Store ID set to target store; Limit set to 20; Sort set to 'name'; Select Fields set to 'name code'.

Links

Discussion