Skip to main content

Fetching URL Filtering Rules Using Pagination and Search Filters

The URL Filtering policy API allows you to retrieve all URL Filtering rules and use server-side search filters to refine the query results. The URL Filtering policy API supports pagination and filtering parameters, allowing users to manage large sets of URL Filtering rules.

Fetching URL Filtering Rules

To retrieve all URL Filtering rules, you must iterate through the paginated results returned by the API. To do this, you must first get the total rule count, then loop through the pages, making a GET request for each page:

  1. Get the total number of rules: Before fetching the rules, make a call using the GET /urlFilteringRules/count endpoint to determine the total number of existing rules.
  2. Loop through the pages: After obtaining the total rule count, calculate the total number of pages required by dividing the total count by page size (totalPages = ceil (total count / page size)). You must then loop from page 1 to total pages, making a GET request for each page.

Here's a pseudocode example:

pageSize = 100 // Or any desired size up to a max limit
totalRulesCount = GET "/urlFilteringRules/count"
totalPages = ceil(totalRulesCount / pageSize)
allRules = []
for page in 1..totalPages:
rulesPage = GET "/urlFilteringRules?page=" + page + "&pageSize=" + pageSize
allRules.append(rulesPage)
// The 'allRules' array now contains the complete ruleset

Leveraging Server-Side Search

Pagination can be combined with server-side search filters to efficiently retrieve specific sets of URL Filtering rules. Filters can be applied using query parameters such as name, location, or other supported fields.

For example:

  • To retrieve all URL Filtering rules with "Finance" in the name field and on the second page, configure the request to GET /urlFilteringRules?name=Finance&page=2&pageSize=100.
  • To get the count of all rules assigned to the "Headquarters" location, configure the request to GET /urlFilteringRules/count?locations=Headquarters.