example that fetches articles from category ID 12 whose title or text matches “joomla”, sorted by newest first and limited to 5 results:
curl -g -X GET \
-H "Accept: application/vnd.api+json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
"https://example.com/api/index.php/v1/content/articles?filter[category]=12&filter[search]=joomla&list[fullordering]=a.created DESC&page[limit]=5&page[offset]=0"
The URL broken down
| Part | Meaning |
|---|---|
/api/index.php/v1/content/articles |
Articles endpoint of the Joomla 4/5 Web Services API |
filter[category]=12 |
Only articles in category ID 12 |
filter[search]=joomla |
Free-text search on the article |
list[fullordering]=a.created DESC |
Sort by creation date, newest first |
page[limit]=5 |
Number of results per page |
page[offset]=0 |
Starting point, for pagination |
yyy
-g(globoff): curl otherwise interprets[and]as URL globbing patterns and throws an error. Alternatively, URL-encode them as%5Band%5D:
have to mask the square brackets for filter with backslashes. For example:
curl -H "Authorization: Bearer MY_AUTH_TOKEN" "https://example.org/api/index.php/v1/content/articles?filter\[featured\]=1"
-------
Spaces in search:
In curl '-g (globoff)' may be used to
No. The brackets belong only to the parameter name (filter[search]), not to the value. The value just needs to be URL-encoded, and in curl the whole URL should be in quotes so the shell doesn’t misread it.
Option 1: encode the space yourself
curl -g -H "Accept: application/vnd.api+json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
"https://example.com/api/index.php/v1/content/articles?filter[search]=joomla%20web%20services"
+ instead of %20 also works in a query string: filter[search]=joomla+web+services.
Option 2: let curl do the encoding
curl -g -G -H "Accept: application/vnd.api+json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
--data-urlencode "filter[search]=joomla web services" \
"https://example.com/api/index.php/v1/content/articles"
Here -G turns the --data-urlencode data into query-string parameters, so you can write the search text with normal spaces. This is the easiest form to read in an article.
Notes
- A raw, unencoded space inside the URL string can cause a 400 error or be cut off, depending on the curl version and server, so don’t rely on it.
- As far as I know, Joomla treats the whole value as one search string rather than splitting it into separate words, so
joomla web serviceslooks for that phrase. I haven’t confirmed this in the docs, so test it on your own installation before stating it in your article.