Fetching Multiple Boundaries Using the Bing Maps API

Balasaheb Molawade 136 Reputation points
2025-06-26T12:48:33.8066667+00:00

Hi,

We are currently using the following Bing Maps API to retrieve boundaries via C#: https://platform.bing.com/geo/spatial/v1/public/geodata?SpatialFilter=GetBoundary(...)

However, this API does not support fetching multiple boundaries at once. We would like to know if there is any other Bing Maps API available that allows retrieving multiple boundaries in a single request.

We appreciate your guidance on this and look forward to your response.

Bing | Bing Search APIs | Bing Entity Search API
{count} votes

2 answers

Sort by: Most helpful
  1. VSawhney 800 Reputation points Microsoft External Staff Moderator
    2025-07-01T11:58:43.31+00:00

    Hello Balasaheb Molawade,

    The Bing Maps REST Services do not support fetching multiple boundaries in a single request directly. However, you can loop through multiple locations and make individual requests for each boundary using C#. Here's a sample implementation:
    Ref doc: https://learn.microsoft.com/en-us/bingmaps/rest-services/using-the-rest-services-with-net

    using System;
    using System.Net.Http;
    using System.Threading.Tasks;
    class Program
    {
        static readonly string bingMapsKey = "YOUR_BING_MAPS_KEY";
        static readonly string baseUrl = "https://platform.bing.com/geo/spatial/v1/public/Geodata";
        static async Task Main(string[] args)
        {
            string[] zipCodes = { "98004", "98005", "98007", "98008", "98039" };
            foreach (var zip in zipCodes)
            {
                string url = $"{baseUrl}?SpatialFilter=GetBoundary('{zip}',1,'Postcode1',1,0)&$format=json&key={bingMapsKey}";
                var boundary = await GetBoundaryAsync(url);
                Console.WriteLine($"Boundary for {zip}:\n{boundary}\n");
            }
        }
        static async Task GetBoundaryAsync(string url)
        {
            using HttpClient client = new HttpClient();
            return await client.GetStringAsync(url);
        }
    }
    

    Hope this helps!
    Thank you!

    0 comments No comments

  2. IoTGirl 3,696 Reputation points Microsoft Employee Moderator
    2025-07-06T18:54:13.3866667+00:00

    Hi @Balasaheb Molawade

    Please consider migrating to https://learn.microsoft.com/en-us/azure/azure-maps/migrate-geodata as the Bing Maps APIs are retiring. You can leverage the "Azure Maps" tag for migration questions regarding Bing Maps for Enterprise.

    https://blogs.bing.com/maps/2025-01/What-are-my-options-regarding-Bing-Maps-for-Enterprise-Retirement

    Sincerely,

    IoTGirl

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.