Where can I find documentation on the Nominatim geocoding response API? - geocoding

I have begun using the Nominatim geocoding API. This page has reasonable documentation on the request parameters to the service. However, I can't find anywhere which details the response. Many of the response fields are obvious, but I would like to know more about osm_type, class, type and their possible values (and what they mean, of course). I would also like to understand what 'importance' refers to. I cannot find documentation on this output. Can anyone point me in the right direction?
Sample output:
[
{
"address": {
"city": "Berlin",
"city_district": "Mitte",
"construction": "Unter den Linden",
"continent": "European Union",
"country": "Deutschland",
"country_code": "de",
"house_number": "1",
"neighbourhood": "Scheunenviertel",
"postcode": "10117",
"public_building": "Kommandantenhaus",
"state": "Berlin",
"suburb": "Mitte"
},
"boundingbox": [
"52.5170783996582",
"52.5173187255859",
"13.3975105285645",
"13.3981599807739"
],
"class": "amenity",
"display_name": "Kommandantenhaus, 1, Unter den Linden, Scheunenviertel, Mitte, Berlin, 10117, Deutschland, European Union",
"importance": 0.73606775332943,
"lat": "52.51719785",
"licence": "Data \u00a9 OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright",
"lon": "13.3978352028938",
"osm_id": "15976890",
"osm_type": "way",
"place_id": "30848715",
"svg": "M 13.397511 -52.517283599999999 L 13.397829400000001 -52.517299800000004 13.398131599999999 -52.517315099999998 13.398159400000001 -52.517112099999999 13.3975388 -52.517080700000001 Z",
"type": "public_building"
}
]

Related

Can I create a Django Rest Framework API with Geojson format without having a model

I have a Django app that requests data from an external API and my goal is to convert that data which is returned as list/dictionary format into a new REST API with a Geojson format.
I came across django-rest-framework-gis but I don't know if I could use it without having a Model. But if so, how?
I think the best way is to use the python library geojson
pip install geojson
If you do not have a Model like in geodjango you have to explicitly describe the geometry from the data you have.
from geojson import Point, Feature, FeatureCollection
data = [
{
"id": 1,
"address": "742 Evergreen Terrace",
"city": "Springfield",
"lon": -123.02,
"lat": 44.04
},
{
"id": 2,
"address": "111 Spring Terrace",
"city": "New Mexico",
"lon": -124.02,
"lat": 45.04
}
]
def to_geojson(entries):
features = []
for entry in entries:
point = Point((entry["lon"], entry["lat"]))
del entry["lon"]
del entry["lat"]
feature = Feature(geometry=point, properties=entry)
features.append(feature)
return FeatureCollection(features)
if __name__ == '__main__':
my_geojson = to_geojson(data)
print(my_geojson)
Create the point geometry from lon, lat (Could also be another geometry type)
Create a feature with the created geometry and add the dictionary as properties. Note that I deleted lon, lat entries from the dictionary to not show up as properties.
Create A feature collection from multiple features
Result:
{"features": [{"geometry": {"coordinates": [-123.02, 44.04], "type":
"Point"}, "properties": {"address": "742 Evergreen Terrace", "city":
"Springfield", "id": 1}, "type": "Feature"}, {"geometry":
{"coordinates": [-124.02, 45.04], "type": "Point"}, "properties":
{"address": "111 Spring Terrace", "city": "New Mexico", "id": 2},
"type": "Feature"}], "type": "FeatureCollection"}
More Info here: Documentation Geojson Library

Amazon Product Advertising API v5 - How to retrieving different type of books (hardcopy, paperback, kindle... ) with one API call

I’m a developer for a company where we’re using Amazon's great product advertising API (PA-API) for a many years for fetching book information. We’re currently using the Java SDK and API v5.
Issue
We provide our customers directly links with our affiliate to the related hardcopy or ebook on different Amazon stores. We do this by creating a SearchItems documentation request with the ISBN (example 9780399562396) as the keyword and no specific search index. In the past we got a response back with two items and therefore two ASINs, one for the hardcopy and one for the ebook (distinguishable by the itemInfo’s product group). However, since some time we had to recognize that the response only contains normally one item, the hard copy product.
I have already tried different approaches with the great Scratchpad.
Questions
The interesting thing is that when I explicitly include the search index (more information here) “Books” or “KindleStore” the API is responding with the expected item (for "books" with a book and for "KindleStore" with a kindle). We do that by having a look at the ItemInfo.Classifications (more information here) However, if I search in the index “All” or don’t specified it, it returns only one item (normally the hardcopy). Which seems to me quite strange… Should the API/search index even behave like this?
Furthermore, I was not able to figure out how to search in to indexes within the same request and it seems to me that this is not supported at all but I would expect that at least this would then return two items…
Therefore, I would like ask you if somebody has an explanation for us to retrieve with one request both ASINs (kindle + hard copy book) of the same ISBN. Of course it is possible to create two separate requests for each product group, however since the API rates are tied to the shipped item revenue, we would like to avoid unnecessary API requests.
Some examples with and without the usage of the explicit usage of the search index
In the following example I looking for the hardcopy or kindle of the book with ISBN 9780262043649 by doing a SearchItem request.
a) Hardcopy with given search index
Payload
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"SearchIndex": "Books",
"PartnerTag": "*********",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
Response
{
"SearchResult": {
"Items": [
{
"ASIN": "0262043645",
"DetailPageURL": "https://www.amazon.com/dp/0262043645?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Hardcover",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Book",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence (The MIT Press)",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&i=stripbooks&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
b) Kindle with given search index
Payload
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"SearchIndex": "KindleStore",
"PartnerTag": "******",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
Response
{
"SearchResult": {
"Items": [
{
"ASIN": "B08BT4MM18",
"DetailPageURL": "https://www.amazon.com/dp/B08BT4MM18?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Kindle Edition",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Digital Ebook Purchas",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&i=digital-text&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
c) No specific search index
Payload
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"PartnerTag": "*******",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
Response
{
"SearchResult": {
"Items": [
{
"ASIN": "B08BT4MM18",
"DetailPageURL": "https://www.amazon.com/dp/B08BT4MM18?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Kindle Edition",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Digital Ebook Purchas",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
Research/Further information
Documentation of the API
Search Index of Amazon
Scratchpad
Many thanks for any advice.

FB Graph API - Filtering results by specific IDs?

I am making a request to a specific node and edge using the graph API:
https://graph.facebook.com/v2.6/NODE_ID/EDGE_NAME
Example:
https://graph.facebook.com/v2.6/00000000000000/reports
which returns the results below:
"data": [
{
"id": "111111111111111",
"name": "Report A"
},
{
"id": "22222222222222",
"name": "Report B"
},
{
"id": "33333333333333",
"name": "Report C"
}
]
The above is literally returning a list of reports by id/name that exist under a specific company.
If I want to filter the results by specific reports, how can I go about doing this?
I tried variations such as the below, but they haven't worked and still return all reports:
https://graph.facebook.com/v2.6/00000000000000/reports?ids=22222222222222
I know I can make the report ID as the node to access it directly:
https://graph.facebook.com/v2.6/22222222222222/
But I want to view the properties of a subset of reports that belong to the company, so I was thinking I could build an array to do this.
https://graph.facebook.com/v2.6/00000000000000/reports?ids=22222222222222,33333333333333
Expected Result:
"data": [
{
"id": "111111111111111",
"name": "Report A"
},
{
"id": "22222222222222",
"name": "Report B"
},
{
"id": "33333333333333",
"name": "Report C"
}
]
This seems like it should work based on the below documentation, but it does not...
https://developers.facebook.com/docs/graph-api/using-graph-api
Could it be because the edge I'm accessing isn't able to recognize these IDs for some reason...? I know it's hard to say without knowing what I'm doing, but I can't disclose fully as it's proprietary...
Any advice is appreciated.

Cloudsearch dynamic fields skipping fields

In cloudsearch (using IMDB data) I added two dynamic fields to the existing indexing options
I then got the entire JSON IMDB data from AWS and added the fields location_t and month_i.
[{
"fields": {
"rating": 7.4,
"genres": ["Comedy", "Drama"],
"plot": "A New Jersey guy dedicated to his family, friends, and church, develops unrealistic expectations from watching porn and works to find happiness and intimacy with his potential true love.",
"release_date": "2013-01-18T00:00:00Z",
"title": "Don Jon",
"rank": 1,
"running_time_secs": 5400,
"directors": ["Joseph Gordon-Levitt"],
"image_url": "http://ia.media-imdb.com/images/M/MV5BMTQxNTc3NDM2MF5BMl5BanBnXkFtZTcwNzQ5NTQ3OQ##._V1_SX400_.jpg",
"year": 2013,
"actors": ["Joseph Gordon-Levitt", "Scarlett Johansson", "Julianne Moore"]
},
"type": "add",
"id": "tt2229499",
"location_t": "Berlin",
"month_i": 8},...
When I uploaded the JSON, it ignored the dynamic fields?
I did it anyway and I tried searching but to no avail. Anyone no what I am doing wrong. I followed the instructions to the book in dynamic fields
You need to have your dynamic fields as a part of your fields array, see below:
[{
"fields": {
"rating": 7.4,
"genres": ["Comedy", "Drama"],
"plot": "A New Jersey guy dedicated to his family, friends, and church, develops unrealistic expectations from watching porn and works to find happiness and intimacy with his potential true love.",
"release_date": "2013-01-18T00:00:00Z",
"title": "Don Jon",
"rank": 1,
"running_time_secs": 5400,
"directors": ["Joseph Gordon-Levitt"],
"image_url": "http://ia.media-imdb.com/images/M/MV5BMTQxNTc3NDM2MF5BMl5BanBnXkFtZTcwNzQ5NTQ3OQ##._V1_SX400_.jpg",
"year": 2013,
"actors": ["Joseph Gordon-Levitt", "Scarlett Johansson", "Julianne Moore"],
"location_t": "Berlin",
"month_i": 8
},
"type": "add",
"id": "tt2229499",},...

JSON.net returning malformed JSON

I am using json.net to parse objects and delivering them to a webservice I have made. The objects are LINQ-objects. When I access this webservice with JQuery, it doesn't parse the JSON correctly. There seems to be something wrong with the formatting..
The JSON-string I get is this one:
[{"typeid":1,
"typename":"binders",
"description":"test",
"RESOURCEs":
[{"resourceid":4,
"resourcename":"Binders 1",
"description":"Pakke med hele fire binders!!!",
"typeid":1,
"RESERVATIONLINEs":[]
},
{"resourceid":10,
"resourcename":"xxx",
"description":"xxx",
"typeid":1,
"RESERVATIONLINEs":[]
}
]
},
{"typeid":2,
"typename":"blyant",
"description":"også dyrt",
"RESOURCEs":
[{"resourceid":5,
"resourcename":"Gråblyant 1",
"description":"Fin og grå",
"typeid":2,
"RESERVATIONLINEs":[]
},
{"resourceid":6,
"resourcename":"Rødblyant 1",
"description":"Må spisses ofte",
"typeid":2,
"RESERVATIONLINEs":[]
}
]
},
{"typeid":4,
"typename":"Penn",
"description":"tester",
"RESOURCEs":
[{"resourceid":7,
"resourcename":"Penn 1",
"description":"Blå og fin",
"typeid":4,
"RESERVATIONLINEs":[]
},
{"resourceid":11,
"resourcename":"xxx",
"description":"xxx",
"typeid":4,
"RESERVATIONLINEs":[]
}
]
},
{"typeid":5,
"typename":"Kajakk",
"description":"Dette er en type båt",
"RESOURCEs":
[{"resourceid":1,
"resourcename":"Havkajakk 1",
"description":"FOr havbruk",
"typeid":5,
"RESERVATIONLINEs":[]
},
{"resourceid":2,
"resourcename":"Havkajakk 2",
"description":"For havbruk",
"typeid":5,
"RESERVATIONLINEs":[]
}
]
},
{"typeid":6,
"typename":"3G-modem",
"description":"Fra NetCom",
"RESOURCEs":
[{"resourceid":3,
"resourcename":"3G-modem 1",
"description":"Gammelt og ustabilg",
"typeid":6,
"RESERVATIONLINEs":[]
},
{"resourceid":12,
"resourcename":"xxx",
"description":"xxx",
"typeid":6,
"RESERVATIONLINEs":[]
}
]
},
{"typeid":7,
"typename":"Minnepinne",
"description":"på 1 KB",
"RESOURCEs":
[{"resourceid":8,
"resourcename":"Minnepinne 1",
"description":"1 KB (!)",
"typeid":7,
"RESERVATIONLINEs":[]
},
{"resourceid":9,
"resourcename":"Minnepinne 2",
"description":"20 PB",
"typeid":7,
"RESERVATIONLINEs":[]
}
]
}]
Anyone have a clue why this is not working?
The actual problem here was that this JSON was embedded in a XML-tag. I solved the problem by parsing the JSON-string by using this parser: http://www.json.org/js.html
Of cource this is not ideal, as JQuery should do this for me, but until I find a way for .NET-webservices to return the raw JSON-string, not embedded in a XML-tag, this solution works =)
I guess this is an encoding problem, what if you remove this from your record?
"resourcename":"Rødblyant 1"
Make sure you are working with UTF-8 on both sides. My guess is that either you are encoding the string using the default encoding (like windows1252), or the receiving end is doing something similar.
Remember that JSON must be in UTF-8, UTF-16 (LE or BE), or UTF-32 (LE or BE).
To test this, get rid of all of the å and ø characters and see if it works. If so, it's definitely encoding on one side or the other.