How to generate city details based on IP?

Anonymous
2023-01-16T12:07:17.37+00:00

Hi Team

Please can someone suggest to me how we can generate city-based details using the IP address?

Azure Maps
Azure Maps

An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.

Locked Question. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

5 answers

Sort by: Most helpful
  1. Sreeju Nair 12,761 Reputation points
    2023-01-16T12:46:37.61+00:00

    Based on my best knowledge, Azure Maps Doesn't offer IP to City mapping. As of now, Azure offers IP-to-country mapping.

    https://learn.microsoft.com/en-us/rest/api/maps/geolocation/get-ip-to-location?tabs=HTTP

    So the IP Address to Location Result shall give the following information

    https://learn.microsoft.com/en-us/rest/api/maps/geolocation/get-ip-to-location?tabs=HTTP#ipaddresstolocationresult

    For IP to City, there are third-party services available. Some of them are given below.

    https://ipinfo.io/

    https://apilayer.com/marketplace/ip_to_location-api

    Hope this helps

    Was this answer helpful?

    2 people found this answer helpful.
  2. rbrundritt 21,711 Reputation points Volunteer Moderator
    2025-12-22T04:26:50.4233333+00:00

    As others have mentioned, Azure Maps only provides country level geolocation details for IP addresses. You would need to use a 3rd party solution for this. If you are looking for something hosted in Azure, here is a solution in the Azure Marketplace: https://marketplace.microsoft.com/en-us/product/saas/fastah.ip_location_api_01?tab=Overview

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  4. rbrundritt 21,711 Reputation points Volunteer Moderator
    2023-06-06T14:14:36.1266667+00:00

    As noted in some of the comments, Azure Maps Geolocation API only provides IP Address locations to country level at this time. I don't believe there is any Azure service that provides city level accurate IP Address to location information. There are non-Microsoft services available in the Azure Marketplace that do provide this functionality, such as this one: https://azuremarketplace.microsoft.com/en-us/marketplace/apps/fastah.ip_location_api_01?tab=Overview

    Was this answer helpful?

    0 comments No comments
  5. QuantumCache 20,681 Reputation points Moderator
    2023-03-10T00:24:42.12+00:00

    Hello,

    Geolocation - Get IP To Location

    You can use Azure Maps to obtain city-based details using an IP address. Azure Maps provides a REST API called "IP Address to Location" that allows you to get the geolocation of an IP address, including the city. Here are the steps to achieve this:

    1. First, you need to sign up for an Azure Maps account and get an API key. You can sign up for a free account that allows up to 250,000 transactions per month.
    2. Next, you can call the "IP Address to Location" API using the following URL:

    https://atlas.microsoft.com/ipAddress/{ipAddress}?subscription-key={subscriptionKey}&api-version=1.0&verbose=true

    Replace {ipAddress} with the IP address you want to get the details for and {subscriptionKey} with your Azure Maps subscription key.

    1. The API returns a JSON response that includes the geolocation details of the IP address, including the city. Here is an example response:
    {
        "type": "Point",
        "coordinates": [
            -122.33207,
            47.60621
        ],
        "properties": {
            "city": "Seattle",
            "state": "Washington",
            "country": "United States",
            "postalCode": "98101",
            "query": "104.44.194.72"
        }
    }
    
    

    As you can see, the response includes the city ("Seattle") in the "properties" section.

    1. You can then parse the JSON response and extract the city name to use it in your application.

    Note that the accuracy of the geolocation details obtained from an IP address may not always be 100% accurate, but it should be sufficient for most use cases.

    Was this answer helpful?