allRoutes
Learn how to effectively use the allRoutes API endpoint.
The allRoutes endpoint retrieves all active routes for a specified siteId or for all sites. This is particularly useful for prerendering your pages.
Basic Usage
To use this endpoint, send a GET request to ${PRIMARY_SITE_URL}/v1/api/queryApi/allRoutes to receive an array of routes for all sites.
If you want to fetch routes for a specific site, append the siteId to the URL. For example for siteId = 1 you could use the endpoint like that: ${PRIMARY_SITE_URL}/v1/api/queryApi/allRoutes/1.
A full example with an access token might look like this:
curl --request GET \
--url 'https://your-site.ddev.site/v1/api/queryApi/allRoutes' \
--header 'authorization: Bearer your-access-token'
Advanced Usage
You can pass an array as a URL parameter to the allRoutes endpoint by encoding the array as a JSON string and then URL encoding it. This allows you to retrieve routes for multiple siteIds in a single request.
Example
To fetch routes for siteId 1 and 2:
https://example.com/v1/api/queryApi/allRoutes?siteIds=%5B1%2C2%5D
Breakdown:
https://example.com/v1/api/queryApi/allRoutes: Base URL of your API endpoint.?siteIds=: Query parameter indicating you’re passing siteIds.%5B1%2C2%5D: URL-encoded JSON string 1,2.%5Bis [%2Cis ,%5Dis ]