1.3 KiB
1.3 KiB
Fetching Rules with Pagination
The API returns rules in pages of 50. All pages must be fetched to ensure no rules are missed.
Algorithm
- Start with
page=1,page_size=50, accumulate results in an empty list - Request:
GET {API_URL}/rules?scopes={ENCODED_SCOPE}&state=active&page={PAGE}&page_size=50- Header:
Authorization: Bearer {API_KEY}
- Header:
- On non-200 response, handle the error and exit gracefully:
401— invalid/expired API key403— access forbidden404— endpoint not found (checkQODO_ENVIRONMENT_NAME)429— rate limit exceeded5xx— API temporarily unavailable- connection error — check internet connection
- Parse
rulesarray from JSON response body - Append page rules to accumulated list
- If rules returned on this page < 50 → last page, stop
- Otherwise increment page and repeat from step 2
- Safety limit: stop after 100 pages (5000 rules max)
API URL
Construct {API_URL} from ENVIRONMENT_NAME (read from ~/.qodo/config.json):
ENVIRONMENT_NAME |
{API_URL} |
|---|---|
set (e.g. staging) |
https://qodo-platform.staging.qodo.ai/rules/v1 |
After Fetching
If total rules == 0, inform the user no rules are configured for the repository scope and exit gracefully.