Getting Started with Webmaster API

Quick start for Bing Webmaster API. Also check out the IWebmasterApi Members

Webmaster Api interface


public interface IWebmasterApi

Here is where you can check out the IWebmasterApi Members


Webmaster API support following protocols:
SOAP - Simple Object Access Protocol
POX/HTTP - Plain Old XML over HTTP
JSON/HTTP - JavaScript Object Notation over HTTP
SOAP protocol url is WSDL can be found on httpps://
To start work with Webmaster Api via SOAP protocol you need to perform following steps:

  1. Create a new C# Console project in Visual Studio.

  2. Right click on the project in Solution Explorer and select the "Add Service Reference" context menu option.

  3. Enter httpps:// in the "Address" edit box.

  4. Enter WebmasterApi in the "Namespace" edit box.

  5. Click "Ok". Visual Studio will generate service reference files and will add service configuration section to app.config.

  6. Open app.config and find the system.serviceModel/client/endpoint section. You have to replace the API_KEY string in the address attribute with your own Webmaster API Key (you have to generate it on the Bing Webmaster Tools site). You will get something like this: <endpoint address="httpps://" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWebmasterApi" contract="WebmasterApi.IWebmasterApi" name="BasicHttpBinding_IWebmasterApi" />

  7. You also need to increase maximum size for incoming messages. Find system.serviceModel/bindings/binding section. Change value of maxBufferSize and maxReceivedMessageSize attributes to 524288 or larger number.

Then you will be able to perform requests to Webmaster API. The following example demonstrates how to print traffic information for the last month to the console (Replace httpp:// with the URL of your site which has been verified in Bing Webmaster Tools).

namespace WebmasterApiExamples
    using System;
    using System.Linq;
    using System.ServiceModel;

    internal class Program
        private static void Main(string[] args)
            var api = new WebmasterApi.WebmasterApiClient();

                var oneMonthAgo = DateTime.Now.AddMonths(-1);
                var stats = api.GetRankAndTrafficStats("")
                    .Where(s => s.Date > oneMonthAgo)
                    .OrderBy(s => s.Date);
                foreach (var value in stats)
                    Console.WriteLine("{0}\t{1}\t{2}", value.Date.ToShortDateString(), value.Impressions, value.Clicks);
            catch (FaultException<WebmasterApi.ApiFault> fault)
                Console.WriteLine("Failed to add site: {0}", fault.Message);

You will find samples for POX and JSON protocols on each of the method pages. In case of errors ApiFault will be generated. A SOAP protocol error can be caught using the following code:

catch (FaultException<WebmasterApi.ApiFault> fault)
    // handle error

HTTP status code 400 will be returned in case of an exception for POX and JSON formats. The body will contain error description:

POX error response sample

HTTP/1.1 400 Error
Content-Length: 97
Content-Type: application/xml; charset=utf-8

<root type="object"><ErrorCode type="number">3</ErrorCode><Message>InvalidApiKey</Message></root>

JSON error response sample

HTTP/1.1 400 Error
Content-Length: 41
Content-Type: application/json; charset=utf-8


See Also


IWebmasterApi Members