Query Parameter Types
This section covers how to pass some common data types as query parameters.
This is useful if you're sending requests to the API endpoints and not using
our JS Client. For example, when using cURL or Postman.
Strings
You can pass a string value in the form of <parameter_name>=<value>
.
For example:
curl "http://localhost:9000/store/products?title=Shirt"
If the string has any characters other than letters and numbers, you must
encode them.
For example, if the string has spaces, you can encode the space with +
or%20
:
curl "http://localhost:9000/store/products?title=Blue%20Shirt"
You can use tools like this one to learn how
a value can be encoded.
Integers
You can pass an integer value in the form of <parameter_name>=<value>
.
For example:
curl "http://localhost:9000/store/products?offset=1"
Boolean
You can pass a boolean value in the form of <parameter_name>=<value>
.
For example:
curl "http://localhost:9000/store/products?is_giftcard=true"
Date and DateTime
You can pass a date value in the form <parameter_name>=<value>
. The date
must be in the format YYYY-MM-DD
.
For example:
curl -g "http://localhost:9000/store/products?created_at[lt]=2023-02-17"
You can also pass the time using the format YYYY-MM-DDTHH:MM:SSZ
. Please
note that the T
and Z
here are fixed.
For example:
curl -g "http://localhost:9000/store/products?created_at[lt]=2023-02-17T07:22:30Z"
Array
Each array value must be passed as a separate query parameter in the form<parameter_name>[]=<value>
. You can also specify the index of each
parameter in the brackets <parameter_name>[0]=<value>
.
For example:
curl -g "http://localhost:9000/store/products?sales_channel_id[]=sc_01GPGVB42PZ7N3YQEP2WDM7PC7&sales_channel_id[]=sc_234PGVB42PZ7N3YQEP2WDM7PC7"
Note that the -g
parameter passed to curl
disables errors being thrown
for using the brackets. Read more
here.
Object
Object parameters must be passed as separate query parameters in the form<parameter_name>[<key>]=<value>
.
For example:
curl -g "http://localhost:9000/store/products?created_at[lt]=2023-02-17&created_at[gt]=2022-09-17"