Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

angelorigo's avatar

Free or cheaper API for Latitude and Longitude data

Hi,

I do send IP address, Latitude and Longitude from contact forms , is there any free API to get Latitude and Longitude available ? wich one have a greater daily limit of requests ? if not free wich are the cheaper apis? today i do use one with a very short limit so some contacts we do receive without Latitude and Longitude data.

0 likes
2 replies
LaryAI's avatar
Level 58

Certainly! There are several APIs available that provide latitude and longitude data based on IP addresses. Here are a few options, including both free and paid services:

Free APIs

  1. ipinfo.io

    • Free Tier: 50,000 requests per month.
    • Endpoint: https://ipinfo.io/{IP}/json
    • Example:
      fetch('https://ipinfo.io/8.8.8.8/json?token=YOUR_TOKEN')
        .then(response => response.json())
        .then(data => console.log(data));
      
  2. ipstack

    • Free Tier: 5,000 requests per month.
    • Endpoint: http://api.ipstack.com/{IP}?access_key=YOUR_ACCESS_KEY
    • Example:
      fetch('http://api.ipstack.com/8.8.8.8?access_key=YOUR_ACCESS_KEY')
        .then(response => response.json())
        .then(data => console.log(data));
      
  3. ip-api

    • Free Tier: 45 requests per minute.
    • Endpoint: http://ip-api.com/json/{IP}
    • Example:
      fetch('http://ip-api.com/json/8.8.8.8')
        .then(response => response.json())
        .then(data => console.log(data));
      

Paid APIs

  1. MaxMind GeoIP2 Precision

    • Pricing: Starts at $0.0001 per query.
    • Endpoint: https://geoip.maxmind.com/geoip/v2.1/city/{IP}
    • Example:
      fetch('https://geoip.maxmind.com/geoip/v2.1/city/8.8.8.8', {
        headers: {
          'Authorization': 'Basic ' + btoa('YOUR_ACCOUNT_ID:YOUR_LICENSE_KEY')
        }
      })
        .then(response => response.json())
        .then(data => console.log(data));
      
  2. ipdata.co

    • Pricing: Starts at $10 for 1,500 requests per day.
    • Endpoint: https://api.ipdata.co/{IP}?api-key=YOUR_API_KEY
    • Example:
      fetch('https://api.ipdata.co/8.8.8.8?api-key=YOUR_API_KEY')
        .then(response => response.json())
        .then(data => console.log(data));
      

Summary

For a free solution with a generous limit, you might want to start with ipinfo.io or ip-api. If you need more requests or additional features, consider a paid service like MaxMind GeoIP2 Precision or ipdata.co.

Make sure to replace placeholders like YOUR_TOKEN, YOUR_ACCESS_KEY, YOUR_ACCOUNT_ID, YOUR_LICENSE_KEY, and YOUR_API_KEY with your actual API keys or credentials.

nexxai's avatar

I use https://geocode.maps.co/ and they seem to have a pretty generous free tier

EDIT: I apologize; I misread your question. MapsCo's API is only for geocoding a physical address, not an IP address

2 likes

Please or to participate in this conversation.