Search API
From api.bview.com
Introduction
The BView search API is based on a RESTful API. Search requests are made by sending HTTP GET requests, with BView returning an XML document as a response.
Search Requests
The search API will be accessible through the following URL: http://www.bview.co.uk/app/frontend/SearchApi<QUERY-STRING>
Search request parameters
The search API will enable third parties to perform searches using the BView search engine. Each search request (HTTP GET request) can include the following parameters within the query string:
| Parameter | Description |
| what | The business category. |
| who | The business name. |
| where | A textual description of a location, e.g. ‘London’, ‘EC2A’, ‘EC2A 1AE’. |
| lat | The latitude of a location (WGS84). Only valid for requests without the ‘where’ parameter. |
| lng | The longitude of a location (WGS84). Only valid for requests without the ‘where’ parameter. |
| max | The maximum number of results that the search will return, number between 0 and 10 (default is 10). At most 10 results will be returned at any one time. However, the search
may, generate more than 10 results, use the page parameter below to page through all the returned results.
|
| sort | The sort order that the search results will be returned in. If ‘0’, then sort by BView score descending, otherwise, if ‘1’ then sort by distance ascending. Sorting by distance, will only be valid for search requests including the ‘where’ or ‘lat’ and ‘lng’ parameters. If the ‘sort’ parameter is not included, then BView will determine the most appropriate sort option. |
| sponsors | The maximum number of sponsored BView listings to return at the top of search results, between 0..3 sponsored listings can be specified (default is to display a maximum of 3 sponsored listings). |
| radius | An optional parameter allowing the search radius to be explicitly specified in metres (maximum of 50000). BView will suitably select a default radius automatically, for any location-based search requests not explicitly specifying a radius. |
| key | A mandatory unique client key, for authenticating each client request. |
| descLength | An optional parameter specifying the length of listing description text to be returned. The default is no text will be returned, equivalent to setting descLength=0. Text will be truncated to the nearest word after being truncated to the required length. |
| page | An optional parameter specifying the page of results to return. Page numbering starts at 0 and the default page is 0. When specifying a page, the max parameter becomes the number of results per page parameter, with a maximum number of 10. |
| whatType | An optional parameter that specifies how to treat the contents of the what parameter. The following values are valid:
When the value of whatType is greater than 1 it must be used in combination with one of the following variables: ‘where’ or ‘lat-lng’. |
| promoCount | An optional parameter that will accept 0 or 1.The default value is 0, when value is set to 1 the listings promotions/vouchers count is returned in response as option element. E.g <promotion-count>1</promotion-count> |
The following business category, name and location search combinations are valid:
- what
- what + (where | lat-lng)
- who + (where | lat-lng)
- what + whatType + (where | lat-lng)
The parameters ‘who’, ‘what’ and ‘where‘, will be validated against the following rules:
- If not blank, then must be a minimum of 2 characters (excluding whitespace characters).
- The length of the text must not exceed 200 characters.
- Valid characters include alpha-numeric and punctuation characters.
NOTE: BView applies UTF-8 encoding to request parameter values.
Example valid search requests
Client ‘1234’, requesting to search for ‘butchers’ in ‘PL1’ (using default search radius), ordered by distance ascending, returning a maximum of 10 results, including no sponsored listings:
http://www.bview.co.uk/app/frontend/SearchApi?what=butchers&where=PL1&sort=1&sponsors=0&max=10&key=1234
Client ‘1234’, requesting to search for ‘HMV’, at a specific geographic location point (using default search radius), ordered by distance, defaulting to retrieve a maximum of 10 results, including a default of 3 sponsored listings:
http://www.bview.co.uk/app/frontend/SearchApi?who=hmv&lat=50.37379747793086&lng=-4.153364171955531&sort=1&key=1234
Client ‘1234’, requesting to search for ‘HMV’, within 20Km around a specific geographic location point, ordered by distance, defaulting to retrieve a maximum of 10 results, including a default of 3 sponsored listings:
http://www.bview.co.uk/app/frontend/SearchApi?who=hmv&lat=50.37379747793086&lng=-4.153364171955531&sort=1&radius=20000&key=1234
Client ‘1234’, requesting to search for ‘HMV’, within 20Km around the centre point of the postal region ‘PL1’, ordered by distance, defaulting to retrieve a maximum of 10 results, including a default of 3 sponsored listings:
http://www.bview.co.uk/app/frontend/SearchApi?who=hmv&where=pl1&sort=1&radius=20000&key=1234
Append showPromoCount variable to the URL to get the promotion count added to the response
http//www.bview.co.uk/app/frontend/SearchApi?what=business&where=EC2A4LE&key=<your-key>&showPromoCount=1
Searching by classification codes, using what type 1, multiple codes coma separated
http://www.bview.co.uk/app/frontend/SearchApi?where=london&what=1360,79&key=<your-key>&whatType=1
Searching by classification codes, using what type 2, multiple categories separated by a pipe symbol |
http://www.bview.co.uk/app/frontend/SearchApi?what=Agriculture|Auto+Repair+%26+Services&where=EC2A4LE&key=<your-key>&whatType=2
To receive the “about” text for each listing specify the length of text required using the descLength parameter.
http://www.bview.co.uk/app/frontend/SearchApi?key=<your-key>&where=PL1&what=food&descLength=400&max=1
Search response
Every search request received and successfully processed through the API, will under normal circumstances, result in an XML response, regardless if the request was erroneous. The XML response will either contain details of an error, or a list of relevant search results.
XML Schema definition
The XML schema definition (XSD) file for the response XML can be accessed at the following address http://www.bview.co.uk/xsd/search_api.xsd. The XSD file should be used in conjunction with this specification document, for understanding the expected XML response format.
Sample listing result XML response
The below sample XML response contains descriptions for two listings, returned from a search result. The first listing is described with the maximum amount of XML content, the second, using only the mandatory XML content.
<?xml version="1.0" encoding="UTF-8"?>
<bview-search xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.bview.co.uk/xsd/search_api.xsd">
<language>en</language>
<datum>WGS84</datum>
<search-radius>10000.0</search-radius>
<listings>
<listing>
<id>0001732</id>
<name>A.M Bence</name>
<link>http://www.bview.co.uk/listing/0001732/AM-Bence-in-PL1</link>
<address>
<addr1>Unit B</addr1>
<addr2>Bence house</addr2>
<addr3>96 King Street</addr3>
<city>Plymouth</city>
<province>Devon</province>
<postal-code>PL1 5JP</postal-code>
</address>
<country>GB</country>
<latitude>50.37379747793086</latitude>
<longitude>-4.153364171955531</longitude>
<phone>01752 667977</phone>
<category>
<category-code>222</category-code>
<category-description>Butchers</category-description>
</category>
<content>
<score>53.49</score>
<review-count>3</review-count>
<relevant-search-link>http://www.bview.co.uk/c/Butchers/Plymouth</relevant-search-link>
<search-proximity>270</search-proximity>
<sponsored>1</sponsored>
<image url="http://www.bview.co.uk/static/ugc/images/rAKSeHg.jpg" url-thumbnail="http://www.bview.co.uk/static/ugc/images/sdfyhs.jpg">
<link>http://www.bview.co.uk/listing/0001732/AM-Bence-in-PL1</link>
<title>A picture of something</title>
</image>
<advert>
<link>http://www.bview.co.uk/listing/0001732/AM-Bence-in-PL1</link>
<body><![CDATA[<p>Get <a href="http://www.bview.co.uk">£35 cashback</a> on car insurance.It is good..</p>]]></body>
</advert>
<voucher>
<link>http://www.bview.co.uk/listing/0001732/AM-Bence-in-PL1</link>
<title>sdsdfsdfsdfsd</title>
</voucher>
<review>
<id>00000000</id>
<link>http://www.bview.co.uk/r/00000000</link>
<title>This is a review title</title>
<user>
<id>2q87bQtTZ3__A7C1iwIXcgEm</id>
<name>Huw2 Lewis</name>
<link>http://www.bview.co.uk/app/frontend/UserProfile?id=2q87bQtTZ3__A7C1iwIXcgEm</link>
</user>
<rating-overall>2.0</rating-overall>
<rating-quality>3.0</rating-quality>
<rating-reliability>1.0</rating-reliability>
<rating-value>2.0</rating-value>
<pros>This business is good</pros>
<cons>This business is not very good</cons>
<date month="6" day="16" year="2008" />
</review>
</content>
</listing>
<listing>
<id>0000266</id>
<name>James Butchers</name>
<link>http://www.bview.co.uk/listing/0000266/James-Butchers-in-PL1</link>
<address>
<postal-code>PL1 1PA</postal-code>
</address>
<country>GB</country>
<latitude>50.37220382729435</latitude>
<longitude>-4.1456694697296514</longitude>
<category>
<category-code>222</category-code>
<category-description>Butchers</category-description>
</category>
<content>
<review-count>0</review-count>
<relevant-search-link>http://www.bview.co.uk/c/Butchers/PLYMOUTH</relevant-search-link>
</content>
</listing>
</listings>
</bview-search>
Sample error XML response
The below XML sample demonstrates an example search error response.
<?xml version="1.0" encoding="UTF-8"?>
<bview-search xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.bview.co.uk/xsd/search_api.xsd">
<language>en</language>
<datum>WGS84</datum>
<error>
<error-code>UNRECOGNISED_LOCATION</error-code>
</error>
</bview-search>
Valid search result XML response
This section describes the composition of the XML response document, returned for each valid search request, returning at least one listing result.
Complex XML types
| Element | Description | Subtags | Parent tag | Attributes |
|---|---|---|---|---|
| listings | This element contains 1..10 listing elements. | listing | bview-search | |
| listing | Represents a single listing. | id, name, link, address, country, latitude, longitude, phone, website, category, content | listing | |
| address | Represents a listing’s address, the postal-code tag is mandatory. | addr1, addr2, addr3, city, province, postal-code | listing | |
| category | The business category of a listing. | category-code, category-description | listing | |
| content | The user-generated content defined for a listing. | score, review-count, relevant-search-link, search-proximity, sponsored, image, advert, voucher, review | listing | |
| image | The primary image to display for this listing, including the URL to the image file and thumbnail image file, the link to a BView page displaying the image, and the title of the image. Example <image url=http://www.bview.co.uk/static/ugc/images/dR3Og.jpg url-thumbnail=”http://www.bview.co.uk/static/ugc/images/4k3Og.jpg”>…</image> | link, title | content |
|
| advert | A listing’s latest promotional advert. The advert text will be included, and a link to a BView page displaying the advert. It is likely that the advert text will contain HTML code, therefore, the advert text will be surrounded within <![CDATA[…]]> tags. | link, body | content | |
| voucher | A listing’s latest promotional voucher. The voucher title will be included, and also a link to a BView page displaying the voucher. | link, title | content | |
| review | Represents a listing’s featured review (a maximum of one featured review per listing). The review author is described within the user subtag. | id, link, title, user, rating-overall, rating-quality, rating-reliability, rating-value, pros, cons, date | content | |
| user | Represents a BView user, consisting of a unique user identification number, a username, and a link to the user’s BView profile page. | id, name, link | review |
Simple XML types
| Element | Description | Subtag of | Example |
| language | This is the language used within the XML document. Currently, the only supported value is ‘en’. | bview-search | <language>en</language> |
| datum | This describes the format used to represent latitude and longitude entries. Currently, the only supported value is ‘WGS84’. | bview-search | <datum>WGS84</datum> |
| search-radius | This element will be present for all location based query requests. The radius would have either been explicitly specified within the request, or the BView search engine would have selected a suitable default radius. | bview-search | <search-radius>25000.0</search-radius> |
| id | A unique identifier for an element, described within the XML document. | listing, review, user | <id>00001234</id> |
| name | The name of a given element. | listing, user | <name>A.M Bence</name> |
| link | A URL link. | listing, image, user, advert, voucher, review | <link>http://www.bview.co.uk</link> |
| addr1 | Represents the first line of a listing’s address. | address | <addr1>Unit B</addr1> |
| addr2 | Represents the second line of a listing’s address. | address | <addr2>House B</addr2> |
| addr3 | Represents the third line of a listing’s address. | address | <addr3>45 High St</addr3> |
| city | Represents the city or town, where the listing is situated. | address | <city>London</city> |
| province | Represents the county where the listing is situated. | address | <province>Hertfordshire</province> |
| postal-code | Represents the listing’s postcode. The postcode is a mandatory address field. | address | <postal-code>PL1 5JP</postal-code> |
| country | The country code for where the listing is situated. Currently, the only supported value is ‘GB’ | listing | <country>GB</country> |
| latitude | Represents a listing’s latitude geo-position, in the format specified within the ‘datum’ tag. | listing | <latitude>50.37379747793086</latitude> |
| longitude | Represents a listing’s longitude geo-position, in the format specified within the ‘datum’ tag. | listing | <longitude>-4.153364171955531</longitude> |
| phone | The listing’s main telephone number. | listing | <phone>01752 667977</phone> |
| website | The listing’s website address. | listing | <website>www.bview.co.uk</website> |
| category-code | BView unique category identifier. | category | <category-code>222</category-code> |
| category-description | Descriptive category name. | category | <category-description>Butchers</category-description> |
| score | The BView listing score, expressed as a percentile value between 0.0 and 100.0. This attribute will not be included for listings without reviews. | listing | <score>53.49<score> |
| review-count | The number of BView reviews written for this listing. | listing | <review-count>3</review-count> |
| relevant-search-link | A URL link, to a relevant, related, business search through the BView frontend, based on the listing’s category and location. | listing | <relevant-search-link>http://www.bview.co.uk/c/butchers/plymouth</relevant-search-link> |
| search-proximity | The listing’s distance in metres from the search location centre-point (only included if a location is supplied in the search request). | listing | <search-proximity>270</search-proximity> |
| sponsored | The presence of this tag, flags a listing as being a sponsored listing. Sponsored listings appear at the top of search results, regardless of order. If present, the value of this element will always be ‘1’. | listing | <sponsored>1</sponsored> |
| title | A textual title/ description. | image, review, voucher | <title>This is a description</title> |
| body | Represents a body of text. | advert | <body>This is some text</body> |
| pros | Positive review text. | review | <pros>This is the positive part of the review</pros> |
| cons | Negative review text. | review | <cons>This is the negative part of the review</cons> |
| rating-overall | The overall review rating, between 0.0 and 5.0. | review | <rating-overall>2.0</ rating-overall > |
| rating-quality | The quality review rating, between 0.0 and 5.0. | review | <rating-quality>2.0</rating-quality> |
| rating-reliability | The reliability review rating, between 0.0 and 5.0. | review | <rating-reliability>2.0</ rating-reliability > |
| rating-value | The value review rating, between 0.0 and 5.0. | review | <rating-value>2.0</rating-value> |
| date | Represents a date. | Attribute: day The ‘day’ attribute represents the day of the month, and can be any value, between 1 and 31. |
Search error XML response
This section describes the composition of the XML response document, returned from an erroneous request. A single response can only include details of one error.
| Element | Description | Subtag of | Example |
| error | Represents an error. | bview-search | |
| error-code | A specific error code:
| error | <error-code>UNRECOGNISED_LOCATION</error-code> |
Authentication
Authentication will be required for all access to the BView search API. Each third party, requiring access to the API, should individually contact BView for a client key. The client key will be unique to each third party, and should be supplied as a URL parameter for every request made to the search API. If the client key is missing from the URL, or fails to authenticate, then an error response will be returned (refer to section 2.4).
Request and Response examples
Append showPromoCount variable to the URL to get the promotion count added to the response
http//www.bview.co.uk/app/frontend/SearchApi?what=business&where=EC2A4LE&key=<your-key>&showPromoCount=1
<bview-search xsi:noNamespaceSchemaLocation="http://www.essential-shallot.co.uk/xsd/search_api.xsd">
<language>en</language>
<datum>WGS84</datum>
<search-radius>2500.0</search-radius>
<listings>
<listing>
<id>2383718</id>
<name>BView</name>
<link>
http://www.essential-shallot.co.uk/listing/2383718/BView-in-EC2A
</link>
<address>
<addr2>27 City Lofts</addr2>
<addr3>112-116 Tabernacle Street</addr3>
<city>London</city>
<postal-code>EC2A 4LE</postal-code>
</address>
<country>GB</country>
<latitude>51.52536847677789</latitude>
<longitude>-0.08447478905020264</longitude>
<phone>0845 680 2001</phone>
<website>http://www.bview.co.uk</website>
<category>
<category-code>218</category-code>
<category-description>Business Information Services</category-description>
</category>
<content>
<score>99.75</score>
<review-count>30</review-count>
<relevant-search-link>
http://www.essential-shallot.co.uk/c/business-information-services/London
</relevant-search-link>
<search-proximity>0</search-proximity>
<image url="http://www.essential-shallot.co.uk/static/ugc/images/listings/aZ/8icSp1KIZx08FvDmnCYSDoXn.gif">
<link>
http://www.essential-shallot.co.uk/listing/2383718/BView-in-EC2A
</link>
</image>
<voucher>
<link>
http://www.essential-shallot.co.uk/listing/2383718/BView-in-EC2A
</link>
<title>£25 Google adwords voucher</title>
</voucher>
<review>
<id>00024033</id>
<link>http://www.essential-shallot.co.uk/r/00024033</link>
<title>BView - a refreshing change</title>
<user>
<id>rP-zuryCU8zuxmbFk6AMsebM</id>
<name>Katherine C</name>
<link>
http://www.essential-shallot.co.uk/app/frontend/UserProfile?id=rP-zuryCU8zuxmbFk6AMsebM
</link>
</user>
<rating-overall>5.0</rating-overall>
<rating-quality>5.0</rating-quality>
<rating-reliability>5.0</rating-reliability>
<rating-value>5.0</rating-value>
<pros>
Pros: It is excellent as a contributor to BView to have a website that is so easy to use, that
you can trust, and is so respo...
</pros>
<date month="9" day="23" year="2008"/>
</review>
</content>
<promotion-count>2</promotion-count>
</listing>
</listings>
</bview-search>
Searching by classification codes, using what type 1, multiple codes coma separated
http://www.bview.co.uk/app/frontend/SearchApi?where=london&what=1360,79&key=<your-key>&whatType=1
<bview-search xsi:noNamespaceSchemaLocation="http://www.essential-shallot.co.uk/xsd/search_api.xsd">
<language>en</language>
<datum>WGS84</datum>
<search-radius>25000.0</search-radius>
<listings>
<listing>
<id>2276595</id>
<name>Hugh's Gallery</name>
<link>
http://www.essential-shallot.co.uk/listing/2276595/Hughs-Gallery-in-WC2N
</link>
<address>
<addr1>7 New Row</addr1>
<city>LONDON</city>
<province>Greater London</province>
<postal-code>WC2N 4LH</postal-code>
</address>
<country>GB</country>
<latitude>51.51103502272706</latitude>
<longitude>-0.1262638828709477</longitude>
<phone>020 78364459</phone>
<category>
<category-code>79</category-code>
<category-description>Art Gallery</category-description>
</category>
<content>
<score>84.77</score>
<review-count>1</review-count>
<relevant-search-link>
http://www.essential-shallot.co.uk/c/art-gallery/LONDON
</relevant-search-link>
<search-proximity>1237</search-proximity>
<image url="http://www.essential-shallot.co.uk/static/ugc/images/reviews/0H/GCKkM5pnDvmqFKa6bl0yEOQe.jpg"
url-thumbnail="http://www.essential-shallot.co.uk/static/ugc/images/reviews/0H/GCKkM5pnDvmqFKa6bl0yEOQe_tn.jpg">
<link>
http://www.essential-shallot.co.uk/listing/2276595/Hughs-Gallery-in-WC2N
</link>
<title>Hugh's Gallery</title>
</image>
<review>
<id>00001187</id>
<link>http://www.essential-shallot.co.uk/r/00001187</link>
<title>London looking it's best</title>
<user>
<id>HYst-ac9kbinRDp8fhL5voNd</id>
<name>James Reynolds</name>
<link>
http://www.essential-shallot.co.uk/app/frontend/UserProfile?id=HYst-ac9kbinRDp8fhL5voNd
</link>
</user>
<rating-overall>4.67</rating-overall>
<rating-quality>5.0</rating-quality>
<rating-reliability>5.0</rating-reliability>
<rating-value>4.0</rating-value>
<pros>
Pros: In Covent garden you can get a glimpse of some the pictures that Hugh's Gallery holds, but
not near as many or as good....
</pros>
<date month="5" day="30" year="2008"/>
</review>
</content>
</listing>
</listings>
</bview-search>
To receive the “about” text for each listing specify the length of text required using the descLength parameter.
<?xml version="1.0" encoding="UTF-8"?>
<bview-search xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.essential-wasabi.co.uk/xsd/search_api.xsd">
<language>en</language>
<datum>WGS84</datum>
<search-radius>2500.0</search-radius>
<listings>
<listing>
<id>0010110</id>
<name>K W Brothers</name>
<link>http://www.essential-wasabi.co.uk/listing/0010110/K-W-Brothers-in-PL1</link>
<address>
<addr1>4-6 Sawrey Street</addr1>
<city>PLYMOUTH</city>
<province>Devon</province>
<postal-code>PL1 3LA</postal-code>
</address>
<country>GB</country>
<latitude>50.36904184935258</latitude>
<longitude>-4.152262860979469</longitude>
<phone>01752 208899</phone>
<about>Proin nisi massa, dapibus non adipiscing egestas, suscipit at arcu. Fusce volutpat magna et ligula
pulvinar venenatis. Integer lobortis interdum eros, ut feugiat erat lacinia a. Lorem ipsum dolor sit
amet, consectetur adipiscing elit. Ut elementum consequat lectus a lobortis.
</about>
<category>
<category-code>774</category-code>
<category-description>Frozen Foods (Wholesale)</category-description>
</category>
<content>
<review-count>0</review-count>
<relevant-search-link>http://www.essential-wasabi.co.uk/c/frozen-foods-(wholesale)/PLYMOUTH
</relevant-search-link>
<search-proximity>297</search-proximity>
<advert>
<link>http://www.essential-wasabi.co.uk/listing/0010110/K-W-Brothers-in-PL1</link>
<body><![CDATA[some text]]></body>
</advert>
</content>
</listing>
</listings>
</bview-search>
Incorrect parameters/combinations and messages
What Type searches 1 & 2 require that one of the following parameters are also supplied : Where or Lat or Long
http//www.bview.co.uk/app/frontend/SearchApi?what=1360,79&key=<your-key>&whatType=1 or http//www.bview.co.uk/app/frontend/SearchApi?what=Agriculture&key=<your-key>&whatType=2
<bview-search xsi:noNamespaceSchemaLocation="http://www.essential-shallot.co.uk/xsd/search_api.xsd">
<language>en</language>
<datum>WGS84</datum>
<error>
<error-code>INVALID_WHAT_TYPE_WHERE_OR_LON_LAT_REQUIRED</error-code>
</error>
</bview-search>
What Type of 1, which requires the what parameter to contain a comma separated list of numerical classification codes
http//www.bview.co.uk/app/frontend/SearchApi?what=Agriculture&where=EC2A4LE&key=<your-key>&whatType=1
<bview-search xsi:noNamespaceSchemaLocation="http://www.essential-cress.co.uk/xsd/search_api.xsd">
<language>en</language>
<datum>WGS84</datum>
<error>
<error-code>
INVALID_WHAT_VALUE_NON_NUMERICAL_CLASSIFICATION_CODE
</error-code>
</error>
</bview-search>
No classifications found for category, in this case because of an incorrect category name
http//www.bview.co.uk/app/frontend/SearchApi?where=PL1&what=AutoRepair+%26+Services&key=<your-key>&whatType=2
<bview-search xsi:noNamespaceSchemaLocation="http://www.essential-cress.co.uk/xsd/search_api.xsd">
<language>en</language>
<datum>WGS84</datum>
<error>
<error-code>NO_CATEGORY_CLASSIFICATIONS_FOUND</error-code>
</error>
</bview-search>
