I am trying to fetch some page stats using GetPageStats method in IWebmasterApi for a url. It returns stats for all the dates. Is there a way to set filter on dates we want the date for? I am sending a GET request through Postman and not using c# program.
Is there a way to filter based on dates in Bing Webmaster API calls?
396 views Asked by Nirmal Manoharan At
2
There are 2 answers
0
On
Hi Not sure this is answering your question, I just start "digging" to develop some app for my use, normally first I read where people complain and fail.
there is some date filter...
You need to see what is the request in C# easy... then reverse engineering and build it in Postman
var oneMonthAgo = DateTime.Now.AddMonths(-1);
var stats = api.GetRankAndTrafficStats("http://yoursite.com/")
.Where(s => s.Date > oneMonthAgo)
.OrderBy(s => s.Date);
https://learn.microsoft.com/en-us/bingwebmaster/getting-started
namespace WebmasterApiExamples
{
using System;
using System.Linq;
using System.ServiceModel;
internal class Program
{
private static void Main(string[] args)
{
var api = new WebmasterApi.WebmasterApiClient();
try
{
var oneMonthAgo = DateTime.Now.AddMonths(-1);
var stats = api.GetRankAndTrafficStats("http://yoursite.com/")
.Where(s => s.Date > oneMonthAgo)
.OrderBy(s => s.Date);
Console.WriteLine("Date\tImpressions\tClicks");
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);
}
}
}
}
After some digging around, I found it is not possible to do a date filter in Bing API calls. Everytime, the entire data (3 months approx) of page stats is sent. The date filter has to be handled in client side.