How to Use the Bing API to Search the Mobile Web

Mobile Web Search Powered By Bing

When Microsoft released the Bing API I speculated that it should be possible to use it to build a real Mobile Web search engine.  By “real” I mean one that would search exclusively for mobile optimized Websites.  I finally got around to trying it today, it was pretty easy, thanks to some some sample code I found on the Bing Developer Website, and it  works surprisingly well.

I wrote my search engine in PHP5.  It uses Bing’s JSON API.  I first  construct a URL containing my Bing API key and the query parameters. The URL looks like this:

http://api.search.live.net/json.aspx?Appid=<Your Bing API Key>&sources=MobileWeb&query=<The Query String>

“&sources=MobileWeb” is the magic incantation that makes Bing return exclusively Mobile Web results. I pass the URL that I built  to  Bing with PHP’s curl_exec().  Bing returns serialized JSON which I parse with another PHP5 function,  json_decode().

Incidentally, in my original piece I wrote that the Bing API has “no usage limits and no restrictions on ordering and blending results”.  This is incorrect, you are restricted to calling the API seven times per second, you can only reorder web (not mobile web) results and if you blend Bing results with results from other sources you must identify which ones come from each source. Still Bing seems to  have the most permissive API of the Big Three search engines. It’s free to use, you can add your own banner ads to results and it’s the only one that lets to to restrict results to the mobile web. There’s a good “plain English” version of the TOS at the end of  this document http://www.bing.com/developers/s/API Basics.pdf which is also a good introduction to the API.

You can download a copy of my working source code from here: bing.zip. You need to replace “<Bing API Key>” at the top of the script with your own API key which you can obtain instantly from www.bing.com/developers.

If you just want to try it out, visit wapreview.mobi/bing.php.  Consider it a proof of concept, it’s lacking in eye candy and needs  more error handling before I’d  call it production ready, but  seems to work well for “normal” queries.

5 thoughts on “How to Use the Bing API to Search the Mobile Web

  1. Pedro,

    The results language can be specified using the “Market” query option:

    api.search.live.net/json.aspx?Appid=<your AppID>&query=news&sources=web&Market=pt-Br

  2. Hi dennis,

    Do you kwnow if it’s possible to narrow the search only in one language (pt-Br, for example).

    Pedro

  3. 404 errors when i try to find a download of the bing.zip…..seems like some useful code, i would love to see it.

Comments are closed.