Get ISO 3166-2 Code from Bing Maps Locations API - bing-maps

Is there a way to get the ISO 3166-2 Code for a specific PostalCode/CountryCode Combination with the Bing Maps Locations API?
Per Example: 1210/AT => AT-9

Use the Bing Maps REST Location API and geocode your query (postal, country...). As part of the request add &incl=ciso2 which will return the country's ISO2 code value. For example:
https://dev.virtualearth.net/REST/v1/Locations?q=1210%2C%20AT&incl=ciso2&key=YOUR_Bing_Maps_Key
Will return the following:
{
"authenticationResultCode": "ValidCredentials",
"brandLogoUri": "http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png",
"copyright": "Copyright © 2017 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.",
"resourceSets": [{
"estimatedTotal": 1,
"resources": [{
"__type": "Location:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1",
"bbox": [48.237850189209, 16.3536491394043, 48.3225288391113, 16.4731197357178],
"name": "1210, Austria",
"point": {
"type": "Point",
"coordinates": [48.2801895141602, 16.4104042053223]
},
"address": {
"adminDistrict": "Vienna",
"adminDistrict2": "Vienna",
"countryRegion": "Austria",
"formattedAddress": "1210, Austria",
"locality": "Vienna",
"postalCode": "1210",
"countryRegionIso2": "AT"
},
"confidence": "High",
"entityType": "Postcode1",
"geocodePoints": [{
"type": "Point",
"coordinates": [48.2801895141602, 16.4104042053223],
"calculationMethod": "Rooftop",
"usageTypes": ["Display"]
}],
"matchCodes": ["Good"]
}]
}],
"statusCode": 200,
"statusDescription": "OK",
"traceId": "cb93431f2caa4f9fb2fcdbaa0ae80b74|CO30324109|7.7.0.0|"
}
Notice in the address property of the response there is "countryRegionIso2": "AT"
Documentation on the Bing Maps REST Locaiton API can be found here: https://msdn.microsoft.com/en-US/library/ff701711.aspx
There is a best practices guide here: https://msdn.microsoft.com/en-us/library/dn894107.aspx
If using .NET you may want to use the Bing Maps REST .NET Toolkit: https://github.com/Microsoft/BingMapsRESTToolkit It makes it really easy to use the REST services in .NET and also has a NuGet package for easily including in your project.

Related

WhatsApp Business API - Edit Template

I'm trying to send a POST request to edit a template message of WhatsApp:
POST /{whatsapp_template_id}
{
"name": "my_template",
"language": "en_US",
"category": "transactional",
"components": [
{
"type": "BODY",
"text": "whatsapp buddy?"
}
]
}
Receiving (#3) Application does not have the capability to make this API call.
Currently, there is no edit template API, as per the documentation it will Available from September 7, 2022.

Mapbox: Find POIs with defined radius

The task I need is:
input: geolocation coordinates from gps, radius
ouput: list of pois (just names) to user can choose
just need analogue for google nearby search (since their cost is too high for a production)
questions:
1) what API is more preferable for this? examples are appreciated
2) do I need own data for pois or there is build in date in mapbox for these purposes?
The Mapbox Tilequery API lets you do exactly this. Here is a step-by-step tutorial explaining how to work with this API, and this API playground lets you experiment with the API. The data queried by the API is determined by the tileset passed as a parameter to your API request. As noted in the linked documentation, tutorial, and playground, you can either use existing Mapbox tilesets are create your own tileset with custom data, depending on your use case.
Note that, depending on the structure of the underlying data in the tileset you use, you might need to do a little extra work to convert a feature returned by the Tilequery API into a name of a POI. For example, consider the response body for below API request which makes use of the default mapbox.mapbox-streets-v8 tileset:
https://api.mapbox.com/v4/mapbox.mapbox-streets-v8/tilequery/-93.1204,44.9472.json?radius=25&limit=5&dedupe&access_token=YOUR_MAPBOX_ACCESS_TOKEN
One particular feature returned by the response body is:
{
"type": "Feature",
"id": 4,
"geometry": {
"type": "Point",
"coordinates": [
-93.12041537130386,
44.947199821761615
]
},
"properties": {
"extrude": "true",
"height": 3,
"min_height": 0,
"type": "house",
"underground": "false",
"tilequery": {
"distance": 1.2132887872688276,
"geometry": "polygon",
"layer": "building"
}
}
}
Although there is no POI name here, you could use the returned coordinates in conjunction with the Mapbox reverse geocoding API endpoint to retrieve names and other relevant POI properties for the POI located at said coordinate.
conversation with Mapbox support
Hi Artemii​,
It's Alex from Mapbox Support, happy to help!
You will want to use the Mapbox Tilequery API. The option you will want to utilize is radius​. Please be advised that queries will use tiles from the maximum zoom of the tileset, and will only include the intersecting tile plus eight surrounding tiles when searching for nearby features. That means that if your tileset has a maximum extent of z20, the maximum radius that you can search is only a few meters. Here is an API playground that you can test the API out with.
I hope this was helpful!
Hi Alex,
thanks for the quick reply, one more question:
request:
https://api.mapbox.com/v4/mapbox.mapbox-streets-v8/tilequery/55.9414,54.7295.json?radius=25&limit=50&dedupe&geometry=point&access_token=YOUR_MAPBOX_ACCESS_TOKEN
response:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": 8,
"geometry": {
"type": "Point",
"coordinates": [
55.94845533370972,
54.72732387401962
]
},
"properties": {
"house_num": "32",
"tilequery": {
"distance": 8.949637333832088,
"geometry": "point",
"layer": "housenum_label"
}
}
},
{
"type": "Feature",
"id": 23629792230,
"geometry": {
"type": "Point",
"coordinates": [
55.948566645383835,
54.72761119224691
]
},
"properties": {
"class": "general",
"filterrank": 4,
"maki": "marker",
"name": "Башинформсвязь",
"name_script": "Cyrillic",
"sizerank": 16,
"type": "Telecommunication",
"tilequery": {
"distance": 23.898768437893523,
"geometry": "point",
"layer": "poi_label"
}
}
}
]
}
question: I understand that I can find info about places I got in the response using reverse geocoding API, but is there another approach to do this? Ideally, I would like to get poi's names from one tilquery request, because in case of using two API's (tilquery + geocoding) I will have to query 4-5 queries instead of only 1 (just worrying because it impacts on cost).
Hi Artemii​,
There is a parameter in the Tilequery API called layers that you can use to target a specific layer of your style.
https://api.mapbox.com/v4/mapbox.mapbox-streets-v8/tilequery/55.9414,54.7295.json?radius=25&limit=50&dedupe&geometry=point&layers=poi_label&access_token=
Which gets this response:
{ "type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": 32316157590,
"geometry": {
"type": "Point",
"coordinates": [
55.94142526388168,
54.7295828683082
]
},
"properties": {
"category_en": "Supermarket",
"category_zh-Hans": "超市",
"class": "food_and_drink_stores",
"filterrank": 1,
"maki": "grocery",
"name": "Магнит",
"name_script": "Cyrillic",
"sizerank": 16,
"type": "Supermarket",
"tilequery": {
"distance": 9.367370433680872,
"geometry": "point",
"layer": "poi_label"
}
}
}
]
}
You can take this response object and return all the information from the POI. The "name" property is the name of the POI. Was there other properties that you were looking for from the reverse geocoding that are not being returned by the tilequery? It would be helpful for you to share a full example of a workflow using both tilequery and reverse geocoding, and to hear more about your exact use case, and how this tilequery/reverse geocoding operation fits into your larger application workflow.
Hi Alex,
request (without poi label since it doesn't find few bars I know. But if you add this label you only see one result) : https://api.mapbox.com/v4/mapbox.mapbox-streets-v8/tilequery/55.9485,54.7275.json?radius=14&limit=50&dedupe&access_token=YOUR_MAPBOX_ACCESS_TOKEN request
response:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": 5,
"geometry": {
"type": "Point",
"coordinates": [
55.9485,
54.7275
]
},
"properties": {
"extrude": "true",
"height": 15,
"min_height": 0,
"type": "building",
"underground": "false",
"tilequery": {
"distance": 0,
"geometry": "polygon",
"layer": "building"
}
}
},
{
"type": "Feature",
"id": 1297495121,
"geometry": {
"type": "Point",
"coordinates": [
55.94833781213748,
54.727526546045794
]
},
"properties": {
"class": "path",
"iso_3166_1": "RU",
"iso_3166_2": "RU-BA",
"len": 4450,
"oneway": "false",
"structure": "none",
"surface": "paved",
"type": "footway",
"tilequery": {
"distance": 10.859473551200084,
"geometry": "linestring",
"layer": "road"
}
}
},
{
"type": "Feature",
"id": 23629792230,
"geometry": {
"type": "Point",
"coordinates": [
55.948566645383835,
54.72761119224691
]
},
"properties": {
"class": "general",
"filterrank": 4,
"maki": "marker",
"name": "Башинформсвязь",
"name_script": "Cyrillic",
"sizerank": 16,
"type": "Telecommunication",
"tilequery": {
"distance": 13.10152056398561,
"geometry": "point",
"layer": "poi_label"
}
}
},
{
"type": "Feature",
"id": 7,
"geometry": {
"type": "Point",
"coordinates": [
55.94869895433047,
54.7274698331467
]
},
"properties": {
"extrude": "true",
"height": 3,
"min_height": 0,
"type": "building",
"underground": "false",
"tilequery": {
"distance": 13.251093067012334,
"geometry": "polygon",
"layer": "building"
}
}
}
]
}
If we decode the first pair of coordinates(55.9485, 54.7275) using reverse geocoding (https://docs.mapbox.com/search-playground), we get Smoky People, ул. Ленина, 32, Уфа, Республика Башкирия 450077, Russia and if we decode all pairs, we will be able to find more cafes and bars (poi's).
Hey Artemii,
The reason for the varied results are the sources of the queries.
The Tilequery API searches for things that are on our Mapbox Streets v8 tileset (which our Mapbox Streets v11 style uses). The data in this tileset majorly comes from OpenStreetMap. If there are missing or outdated places on the map, this is the perfect opportunity to help us improve our map! If you do want to add or edit anything, head to openstreetmap.org, create an account, and make improvements directly. You'll have the option to go through an interactive tutorial to get you started. There are more details for advanced editing here as well: https://labs.mapbox.com/mapping. The Mapbox Streets tileset is updated regularly as features are edited or added to the map, which means that if you edit OpenStreetMap, you will eventually see your changes reflected on your Mapbox map.
The Geocoding API contains data sources from governments, open data projects, and private companies. In some cases, results from the Geocoding API may differ from Mapbox Streets or OpenStreetMap data. Check out this documentation on how geocoding works at Mapbox.
I think the best way to reduce the amount of API calls you make would be to pick one API, either reverse geocoding or Tilequery, and stick with it. With OpenStreetMaps, as tedious as it sounds, you do have the ability to add any POIs you know are missing, or cross reference other sources to add POIs to the map, which will make the place visible on the map as well as appear in your tilequery. With the Geocoding API, due to the nature of some sources and licensing, not all the places that you can search are visible on the map.

How to get a region list in IBM cloud object storage using Rest API

I need a Get Region List in IBM Cloud Object Storage using Rest API. For Example :us-east,au-syd etc.I didn't find any API references related to get Region List.
You may want to retrieve the region endpoints.
Try using the following rest api call:
https://[username]:[apiKey]#api.softlayer.com/rest/v3/SoftLayer_Network_Storage_Hub_Cleversafe_Account/[accountId]/getEndpoints
Output:
[
{
"legacy": true,
"location": "us-south",
"region": "regional",
"type": "public",
"url": "s3.us-south.objectstorage.softlayer.net"
},
{
"legacy": true,
"location": "us-east",
"region": "regional",
"type": "public",
"url": "s3.us-east.objectstorage.softlayer.net"
},
{
"legacy": true,
"location": "eu-gb",
"region": "regional",
"type": "public",
"url": "s3.eu-gb.objectstorage.softlayer.net"
},
]
Reference:
https://sldn.softlayer.com/reference/services/SoftLayer_Network_Storage_Hub_Cleversafe_Account/getEndpoints/
Hope this helps.

How can Mobile App Builder get location (lat, long) data from Cloudant?

I am trying to read location type data from Cloudant into Mobile App Builder (MAB). It looks like MAB is unable to parse it. If I manually create the column still is unable to match it with the data coming from Cloudant
{
"_id": "d07165c0087a05b8ae732266dc37f106",
"_rev": "8-76f0947057bf237bc897adc20f838ce9",
"Name": "Morrisville Location",
"Address": "87 Peste Drive",
"Phone": "919-278-1122",
"Email": "morrisville#store.com",
"Location": {
"Latitude": "35.808514",
"Longitude": "-78.812794"
}
}
What format should I use for location data so MAB can parse it ?
The following worked for me:
{
"_id": "d07165c0087a05b8ae732266dc37f106",
"_rev": "8-76f0947057bf237bc897adc20f838ce9",
"Name": "Morrisville Location",
"Address": "87 Peste Drive",
"Phone": "919-278-1122",
"Email": "morrisville#store.com",
"Location": {
"type": "Point",
"coordinates": [-78.812794, 35.808514]
}
}
Note: Order in coordinates array is [longitude, latitude]
Reference: https://docs.cloudant.com/geo.html and http://geojson.org/geojson-spec.html#appendix-a-geometry-examples
This very first experimental version of Mobile App Builder does not support nested objects at this time.
Here, I've removed the nested object and it works:
See:
IBM mobile app builder does not see documents in Cloudant database, why?
To answer my own question: This is not possible today given the limited parsing features of the current tool. Thanks for the comments and feedback.

Insights before 2010-04-02 are missing?

I'd like to get Insights data before 2010-04-02, but it seems to be impossible to retrieve via the Graph API or FQL query. If you make a Graph API request spanning over 2010-04-02 you will get results starting at 2010-04-02 and going forward with the rest simply missing. Can any one explain this or have a way to get around this limitation?
Here is an example of the problem: http://developers.facebook.com/tools/explorer/?method=GET&path=2439131959%2Finsights%2Fapplication_active_users%3Fsince%3D2010-03-28%26until%3D2010-04-10%26date_format%3DY-m-d
There should be results from 2010-03-28 to 2010-04-10, but you only get 2010-04-02 and onwards.
{
"data": [
{
"id": "2439131959/insights/application_active_users/day",
"name": "application_active_users",
"period": "day",
"values": [
{
"value": 172118,
"end_time": "2010-04-02"
},
{
"value": 177263,
"end_time": "2010-04-03"
},
{
"value": 176568,
"end_time": "2010-04-04"
},
{
"value": 190725,
"end_time": "2010-04-05"
},
...
Maybe your insights were a "victim" of this: https://developers.facebook.com/docs/reference/fql/insights/
We are deprecating some old insights. These metrics are marked as
deprecated throughout this document. After 12/21/2011, data for these
metrics won't be available prior to 07/19/2011 -- please download this
data before this 12/21/2011. These insights will be completely removed
from API after 02/15/2012.