Getting Location from an IP Address

The Ipregistry API enables geolocation lookup for IPv4 or IPv6 addresses. It includes the country, city, region, postal code, borders, population but also carrier data, company, domain name and more.

Below are some common usage patterns for a variety of programming languages and libraries:

Make sure to replace tryout by your own API key before using the following examples in production. The tryout API key used in these examples is heavily rate limited and is meant only for a few initial tests.
The code snippets provided hereafter make use of the origin endpoint. This endpoint returns IP info for the device that runs the code. If the code is run on client-side, it's most probably what you want. If you run the code on server-side, then you should use the single lookup endpoint by passing the client IP in the URL as follows:
where is the client IP address you want to get information for. How to retrieve the client IP address from your server depends on the technology used but usually, you have a header that you can parse such as X-Forwarded-For.
The following code snippets are basic and do not handle possible error cases. For advanced use cases, we recommend using Ipregistry client libraries.


C# (using RestSharp)


Javascript (Vanilla)

Javascript (using Fetch)



Single IP lookup

Batch IP lookup

NodeJS (Vanilla)

Python 2

Python 3