Getting Location from an IP Address

The Ipregistry API enables location lookup for IPv4 or IPv6 addresses. It includes the country, city, region, postal code, borders, population and more.

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

Replace YOUR_API_KEY by your own API key in the following to get a working example.
The following are basic code snippets for quick testing. They do not handle possible error cases. For advanced use cases, we recommend using Ipregistry client libraries.

Bash

Javascript (Vanilla)

Javascript (Fetch)

jQuery

PHP

NodeJS (Vanilla)

Python 2

Python 3

Ruby