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.

This feature works with JSON responses only. If you set XML as output format, the fields parameter will have no effects.
Once filtered, the output is still a JSON document: outputted fields remain nested. If your purpose is to get values that you can use directly from your command-line or shell, we recommend using a lightweight JSON utility command such as jq:

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
Note that characters must be URL encoded before submitted. Characters %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