Fortinet black logo

REST API Solution Guide

Filtering query results

Filtering query results

Queries to the API can be to modify the query/response format or to filter the results. Below are some arguments that can be passed to the REST API URL. Please refer to the specific resource documentation to find out which of these filter operations are allowed.

?format=[format_type] = where format _type= xml or json (default)
?limit=[integer] = where integer specifies number of records to return (default = 20)
?offset=[integer] = where integer specifies number of items in resource list to skip e.g. if there are 10 items, to return item #5 - #10 only, specify offset=4
?order_by=[field] = order returned list by a known field name (e.g.?order_by=name)

Field filters

  • exact: search for an exact match
    (e.g. to return items that has a name matching "John Doe", name__exact=John Doe)
  • in: search for items that matches specific filter criteria
    (e.g. to return items that has a name matching "John" or "Bill", ?name__in=John&name__in=Bill)

View pages for large lists

By default, the API record query limit is set to 20, or can be set up to a maximum of 1000. This value is controlled by the limit, as shown in the table above. Note that this only determines how many records are returned and displayed per page.

REST API uses multiple pages when there are a large number of entries in the list. In order to get the following pages, use the next field from the response (see example below):

{"meta": {"limit": 1000, "next": null, "offset": 0, "previous": null, "total_count": 3}

When the response is the last page, next is set to null. Otherwise, set next to a URL that can be used in a subsequent REST API request to get the next page of records. For example:

{"meta": {"limit": 20, "next": "/api/v1/localusers/?offset=20&limit=20&format=json", "offset": 0, "previous": null, "total_count": 23}, "objects": [{ ...

Filtering query results

Queries to the API can be to modify the query/response format or to filter the results. Below are some arguments that can be passed to the REST API URL. Please refer to the specific resource documentation to find out which of these filter operations are allowed.

?format=[format_type] = where format _type= xml or json (default)
?limit=[integer] = where integer specifies number of records to return (default = 20)
?offset=[integer] = where integer specifies number of items in resource list to skip e.g. if there are 10 items, to return item #5 - #10 only, specify offset=4
?order_by=[field] = order returned list by a known field name (e.g.?order_by=name)

Field filters

  • exact: search for an exact match
    (e.g. to return items that has a name matching "John Doe", name__exact=John Doe)
  • in: search for items that matches specific filter criteria
    (e.g. to return items that has a name matching "John" or "Bill", ?name__in=John&name__in=Bill)

View pages for large lists

By default, the API record query limit is set to 20, or can be set up to a maximum of 1000. This value is controlled by the limit, as shown in the table above. Note that this only determines how many records are returned and displayed per page.

REST API uses multiple pages when there are a large number of entries in the list. In order to get the following pages, use the next field from the response (see example below):

{"meta": {"limit": 1000, "next": null, "offset": 0, "previous": null, "total_count": 3}

When the response is the last page, next is set to null. Otherwise, set next to a URL that can be used in a subsequent REST API request to get the next page of records. For example:

{"meta": {"limit": 20, "next": "/api/v1/localusers/?offset=20&limit=20&format=json", "offset": 0, "previous": null, "total_count": 23}, "objects": [{ ...