Filtering Response
To save bandwidth and speed up response times, the Ipregistry API's fields
parameter can be used to limit API results to a set of fields.
This parameter is supported by all API endpoints. To use this feature, append the fields
parameter to your API request URL and specify as value the fields to return, separated by a comma.
JSON
responses only. If you set XML
as output format, the fields
parameter will be ignored.curl -s "https://api.ipregistry.co/?key=tryout&fields=location.country" | jq ".location.country.code"
Selecting a single field
For instance, returning connection information and its subfields:
https://api.ipregistry.co/66.165.2.7?key=tryout&fields=connection
Selecting multiple fields
Separate a series of fields with a comma:
&fields=connection,security
Selecting a single nested field
Use the dot syntax to access a single nested field:
&fields=security.is_bogon
The dot syntax works for multi-level accesses:
&fields=location.country.name
Selecting multiple nested fields
You can combine the dot syntax and commas:
&fields=security.is_bogon,security.is_tor
In the case you want to return several fields from the same level, use square brackets [
and ]
:
&fields=location.country%5Bcapital,code,name%5D
%5B
and %5D
are respectively the encoded version of [
and ]
.Excluding fields
In order to exclude fields, you need to prefix the field name with a minus sign -
:
&fields=-location
Since the value of an empty field performs an empty selection, you may need to first select all fields before applying exclusions:
&fields=**,-location
In case you exclude fields using the dot syntax, the exclusion applies to the last field.
&fields=currency,-currency.code