Bing Maps REST API response does not return any coordinates even response is "OK" and X-MS-BM-WS-INFO is "1" - rest

We have a .NET application that retrieve a geolocation based on unstructured query, e.g.,
http://dev.virtualearth.net/REST/v1/Locations?q=Australia%20Homebush%20Bay&key=
In our network the response is "OK" and returned the coordinates in JSON format, but in another network (e.g., customer network), the response is "OK" but the "coordinates" does not return any items, or "0" estimatedTotal.
When we used Fiddler, the X-MS-BM-WS-INFO is "1".
Please advise.

This is documented here: http://msdn.microsoft.com/en-us/library/ff701703.aspx under Error Handling. When the X-MS-BM-WS-INFO is "1" this indicates that the request has been rate limited. Rate limiting occurs on trial and basic Bing Maps accounts when the frequency of requests is such that your account will exceed the free usage allowance.

Related

Bing maps Rest API objects not the same

I need to create an API services that calls Bing maps Rest API gets Address, Elevation and latitude and longitude values.
I see that there a Autosuggest that returns an Address object, I also see you have Find location by address api that also returns an Address object. My question is why both address object are not the same? and can it be the address adding the missing fields ?
As I need all the values from the address object from Autosuggest .I would like to call the Find location by address api and get a list of address with the latitude and longitude values as well. Currently I making 3 api calls
The autosuggest and Location APIs, do use the same Address class/object, however this is a lower-level property of the main response from each API.
The autosuggest API returns an autosuggest response that can contain a LocalBusiness, Place, or Address object. All of these have an address property that is an Address object. The __type property in these responses provide an additional insight on the type of result.
The location APIs, return a Location object that has an address property that is the same Address object used in the autosuggest API.
There are some differences in the response objects, but they all include the same Address object.
The autotsuggest responses do not include location details such as latitude/longitude as this information has a higher cost and including this information would mean this service would have to have the same cost per request as the Location API. By separating out this information, the Autosugget API only generates a 1/10th of a transaction per request (10 times cheaper than the Location API). Since in a normal autosuggest experience, a user will likely generate 5 to 10 requests to this service, when typing a single input, this makes the overall cost of this experience significantly cheaper. If each request was charged a full transaction, most companies would quickly find the cost of this experience to be extreme.
For your scenario, the expectation would be atleast 3 requests as defined below.
One or more to the autosuggest API with the users input.
One taking the formattedAddress value from the Address object in the autosuggest response and passing it into the location query API to get the latitude/longitude details.
One taking the latitude/longitude information into the elevation API. Note you can pass in multiple points into this API, and thus get the elevations for an array of address coordinates.

API error when requesting full size data from Alphavantage

I am working on analysing some historical stock market data for Australian shares. I am using Alphavantage as my API to get the actual data.
My problem relates specifically to the TIME_SERIES_DAILY function with FULL outputsize. For some shares, I receive an error message in response to an API call:
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=SUL.AUS&outputsize=full&apikey=XXXXXXXXXXXXXX
{
"Error Message": "Invalid API call. Please retry or visit the documentation (https://www.alphavantage.co/documentation/) for TIME_SERIES_DAILY."
}
If I change the outputsize argument to 'compact' it works but only returns a subset of data I am after.
The bizarre thing is that the full size response works for about 60% of the stocks I am after. After a bit of trial and error, I deduce that the API returns an error for specific shares everytime and not others.
I presume that there may be some feature about these specific shares that causes it to fail - I just don't know what.
This is a known error with Alpha Vantage. See here for more details.
When there is an issue with data past 100 days, instead of returning bad data, it scraps the return as to not throw off algos.

Bing Maps REST API Basic key returns different results than Enterprise key

This unstructured format
http://dev.virtualearth.net/REST/v1/Locations?addressLine=3712%20Adelaide&adminDistrict=TX&locality=The%20Colony&countryRegion=US&postalCode=75056&maxRes=1&key=YourKey
does not seem to return the same result as this structured format
http://dev.virtualearth.net/REST/v1/Locations/US/TX/75056/The%20Colony/3712%20Adelaide?o=json&key=YourKey
The structured format is returning high confidence and the unstructured format is returning medium. What am I missing?
Edit: I never would have expected this. I have discovered the unstructured format returns medium confidence with my current API key and returns high confidence with a new trial key. What does this mean?
Trying the URL's you provided I see the exact same results with the same high confidence value.
Here is the response from the Microsoft Bing Team:
Issue Definition: Question regarding Bing Maps REST Location API service. Scope Agreement: As per our communication, you provided a query for 3712 Adelaide, The Colony, TX 75056 with the Bing Maps REST Location API with a Basic and Enterprise key and received different results and you would like to know the reason. The reason you are receiving different results is because we are in the middle of deploying new information to the Bing Maps REST geocoder. This information is first flighted on Basic (free) accounts before it is released to Enterprise customers.
Our Product Group let us know that it should be deployed to all Enterprise customers by the end of this month.

Sending application specific messages

There is a change to our business logic, where earlier with one of the APIs we use to return a list, for eg. list of employees. Recently we introduced authorization checks, to see if a particular user has permission to view a specific employee.
If say there are 10 employees that should be returned through method GET, due to the missing permission only 5 are returned. The request itself in this case is successful. I am currently not sure how to pass on the information back to the client that there were 5 employees that are filtered out due to missing permission.
Should this be mapped to HTTP status codes? If yes, which status code fits this? Or this is not an error at all?
What would be the best approach in this case?
A status code by itself wouldn't be sufficient to indicate the partial response. The status code 206 sounds close by name but is used when a client specifically requests a partial set of data based on headers.
Use 200. The request was fulfilled successfully after all, and the reason for the smaller set of data is proprietary to your API so extra metadata in the response to indicate a message might be sufficient.
Assuming JSON response:
{
"data": [ ... ],
"messages": [
"Only some data was returned due to permissions."
]
}
If you have many consumers and are worried about backward compatibility you may also want to provide a vendor specific versioned JSON media type:
"Content-Type": "application/vnd.myorg-v2+json"

Youtube REST API v3 - include statistics for video in search query result

I want to perform search queries using Youtube API v3.
What I need is to retrieve video ids and statistics for each video.
From the docs I can see that statistics is not returned for video items. If I try to ask for statistics using this query:
https://www.googleapis.com/youtube/v3/search?type=video&part=snippet,statistics&q=kittens&key={MY_KEY}
I receive an error:
{
"error": {
"errors": [
{
"domain": "youtube.part",
"reason": "unknownPart",
"message": "statistics",
"locationType": "parameter",
"location": "part"
}
],
"code": 400,
"message": "statistics"
}
}
So I guess that I need to make two requests:
Perform actual search and retrieve list of video ids.
Make API request https://developers.google.com/youtube/v3/docs/videos/list to retrieve statistics for each video.
Or maybe I'm missing something and there's a way to get statistics for videos within one search query?
In the guide, they specify "the part names that you can include in the parameter value are id and snippet" when using https://www.googleapis.com/youtube/v3/search. (statistics is not an accepted value).
So I think that you have to make two requests as you say, at least that is what I'm doing. I couldn't find any other solution. I would be interested to know if there was a workaround...
To avoid redundancy of data returned and not to use bandwidth with extra data, "video search data" and "video statistics" data are decoupled in API.
You are right about two calls.
In general, to get faster response, only use the "part" s in request that you will use in your application.