Rendering Bing search with JSRender using API

JSRender is a jscript template engine very much similar to JQuery templates. It is replacing JQuery templates in the near future and still in beta. The main advantage of any template engine is to reduce the jscript code for rendering dhtml with some data. JSRender can be used with or without using JQuery.

Please visit below link to know more about JSRender

[http://borismoore.github.com/jsrender/demos/index.html](http://borismoore.github.com/jsrender/demos/index.html)

Here, in this example, I will try to explain how you can use Bing Search API to render a search interface with JSRender.

Bing Search API exposes http endpoints that can provide results in XML or JSON. Please visit below link for more information on Bing Search API

[http://www.bing.com/developers/s/APIBasics.html](http://www.bing.com/developers/s/APIBasics.html)

Bing API URL format

**Json**

http://api.bing.net/json.aspx?parameters

**XML**

http://api.bing.net/xml.aspx?parameters

Bing Search API request consists of following required and optional parameters

**Required**

1) AppID : Your site application key provided by Bing.

2) Query: Search text

3) Sources: Web or Images etc..

Optional

1) Web.Offset: Offset 0 means first page

2) Web.Count: Total number of records to be fetched.

>Please note that in order to hide my APPID and misuse, I have installed an application on my server to reverse proxy bing api. What I mean is in the example code there is no direct api calling to bing website but it has to go through my site.

http://bing.rajbandi.net/search/json.aspx

or

http://bing.rajbandi.net/search/xml.aspx

All the api requests initiated to my site doesn’t require any APIID but Query and sources parameters are required.

Demo
———-
———

[http://demos.rajbandi.net/bing/search/jsrender.html](http://demos.rajbandi.net/bing/search/jsrender.html)

Source
————
————

Access source at JSFiddle.net
[http://jsfiddle.net/rajbandi/7XNbS/](http://jsfiddle.net/rajbandi/7XNbS/)

Leave a Reply

Your email address will not be published. Required fields are marked *