How to get number of search result from Bing API - bing-api

I want to use bing search api to obtain search result count for given query, however, Bing API seem to not return any fields containing the search result count.
Should I specify some option to request URL? Or Bing API not return the result countt?

You can obtain the result count, but it's not as obvious as I thought it would be.
Using this URL:
https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Composite?Sources=%27web%27&Query=%27YOUR_QUERY_HERE%27&$top=1&$format=JSON
you can get a JSON String, which includes the result count in
d->results[0]->WebTotal
You need to use the Composite search for that (I specified only web in this example, but you can use web+news or any other bing source) and you have to retrieve at least one result ($top=1).
You can also use Atom instead of JSON to get an xml response.

For those subscribed to the SearchWeb stream rather than the general Search, the URL is this:
https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/v1/Composite?Query=%27YOUR_QUERY_HERE%27&$top=1&$format=JSON
As with Wang Tang's answer, the result should include
d->results[0]->WebTotal

You can get the results count from the result object:
results_object['searchResults']['webPages']['totalEstimatedMatches']

Related

Find Place requests Returns Only One Result

I'm using the Google Places API endpoint "findplacefromtext" and tried a search similar to the example.
https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=mongolian%20grill&inputtype=textquery&fields=photos,formatted_address,name,opening_hours,rating&locationbias=circle:2000#47.6918452,-122.2226413&key=YOUR_API_KEY
However, when you use this it only ever returns one result. There is a cafe near me that's called "Cream" but when you pass that as the "input" parameter it returns shops that have a category of "Ice Cream". I thought it should only search the name of the business.... If I can't find the place by name does it search the category type as a fall back? When I execute the same search in Google Maps it returns the same data but I get multiple results and I can see the place I am trying to retrieve 3rd on the search result list.
Is it possible to make it return more than one result? The documentation doesn't mention anything about this.
I believe what you need is the Text Search request. The Find Place request is meant for exact addresses.
The Google Places API Text Search Service is a web service that
returns information about a set of places based on a string — for
example "pizza in New York" or "shoe stores near Ottawa" or "123 Main
Street". The service responds with a list of places matching the text
string and any location bias that has been set.
The service is especially useful for making ambiguous address queries
in an automated system, and non-address components of the string may
match businesses as well as addresses. Examples of ambiguous address
queries are incomplete addresses, poorly formatted addresses, or a
request that includes non-address components such as business names.
Taken from https://developers.google.com/maps/documentation/places/web-service/search#TextSearchRequests

FHIR Page number support

Foe search interactions, while there is support for specifying the number of items expected in the response using the _count parameter, we are not able to find any reference to a parameter to specify the page number.
The _query parameter can be used for custom queries, but is that an option or is there a better alternative.
For example, what is the standard way to request for the second page of a patient resultset with each page having 10 records? -
GET Patient?_count=10&[pagenumber?]=2
There's no mechanism to navigate to a specific page. You use the URLs provided in Bundle.link (e.g. previous, next, first, last) to navigate through the search result set.

RegionCode in YouTube API v3

I can't seem to find any information on the implications of using/not using regionCode in the YouTube v3 API, for example the search/list resource.
In the specific, if the regionCode is not specified in the call to the API, will all the videos matching the criteria be returned?
If a video is allowed only in certain regions, not specifying the regionCode in the search request, will the API return it? Or only the unrestricted videos will be returned?
Where can I find some clarification on the topic?
If you do not specify the Region Code then the API automatically determines the region based on your location. So, for example, if I queried the API on my laptop in New Zealand, then the region code would be NZ.
The API outputs the region code. In JSON it is under the tag regionCode.
Generally Region Code is not required. You will get a good matching results output without it.
The regionCode parameter instructs the API to return search results for the specified country. The parameter value is an ISO 3166-1 alpha-2 country code. (string)

How to sort results by distance with google places api using textsearch

I want to get all the restaurants near my location order by distance.
I am using textsearch with google places api using this url : https://maps.googleapis.com/maps/api/place/textsearch/json?query=restaurants&location=32.16107,34.806618&radius=200&sensor=true&key=api_key. The results that I am getting are sparse with no order what so ever. I tried rankby=distance but accurding to the documentation (https://developers.google.com/places/documentation/) you can use it only with regular search,means that when using textsearch there is no such parameter option (I tried it anyway -> not working).
I am using textsearch because regular search returns only "types" : [ "establishment" ].
How can I order by distance the textsearch of google place api ? I can't believe that google didn't create a way to do it...
You are correct, Places API Textsearch does not support the rankBy=distance parameter. If you believe that this would be a useful feature, please submit a Places API Feature Request.
You can however obtain the result you are looking for by performing a Places API Search Request using the rankBy=distance parameter and the keyword=restaurant parameter:
https://maps.googleapis.com/maps/api/place/search/json?keyword=restaurant&location=32.16107,34.806618&rankBy=distance&sensor=false&key=YOUR_API_KEY
The keyword parameter is matched against all available fields, including but not limited to name, type, and address, as well as customer reviews and other third-party content.

How to get results for a specific country/region only, via Google AJAX Search or Custom Search APIs?

I just want to specify a region and a search phrase, and retrieve the URLs of the top 10 result pages for that search phrase/region from Google...
Add &gl=country_code to the request URL
Example:
http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=music&gl=in

Resources