Enforce MapBox Geocoding API to return only results with a zipcode - api

I'm working with MapBox Geocoding API to have suggestions of addresses in the location search feature of my website.
The following is a sample call:
https://api.mapbox.com/geocoding/v5/mapbox.places/Zur.json?country=ch&limit=5&proximity=8.765.432&language=en-GB&access_token=***
My goal is to enforce the api to return only results that include a zipcode.
For example if I input "Zur" (limiting the search to Swiss) I get the following:
- Zürich, Zürich, Switzerland
- Zürich, Switzerland
- Zürich Airport, Flughafenstrasse, Kloten, Zürich 8302, Switzerland
- Zurich, Buchs, Zürich 8107, Switzerland
The expected results should be without the first two lines, as they don't have a zipcode.
I tried implementing myself the removal of results without the zipcode on client side (just after I got an answer from the api), but it is a suboptimal solution (for example it doesn't ensure to have enough results).
I was not able to find such feature in MapBox. Is there a better solution out of there?

Just add ?types=address
See all list of types:
https://docs.mapbox.com/api/search/geocoding/#data-types

Related

How can I query Wikidata API to get details of all the Korean films?

If possible, i want to return the results in Json or XML format. Is there any ways to do so? Earlier I did it using freebase.com but it is now deprecated. Please help.
This query would look a lot like the one to get the list of all films on Wikidata but adding another filter:
instead of http://wdq.wmflabs.org/api?q=claim[31:11424] (return all the entities marked as instances of film), you would do
http://wdq.wmflabs.org/api?q=claimCLAIM[31:11424] AND CLAIM[495:884] (return all the entities marked as instances of film and South Korea (Q884) as country of origin (P495))
http://wdq.wmflabs.org/api?q=claimCLAIM[31:11424] AND CLAIM[495:423] (the same for North Korea (Q423))
Then to parse the results and get the entities data, it would be the same as for the list of all the films
Remarques:
you will probably need to encode those URLs to get something that looks like: http://wdq.wmflabs.org/api?q=CLAIM%5B31%3A11424%5D%20AND%20CLAIM%5B495%3A884%5D
here is the full API documentation. Notice that this is an experimental API, which might be replaced in the coming year
The overview on Wikipedia may be more complete than Wikidata, as you've noticed yourself also. However, I could only find overviews per year, such as on https://en.wikipedia.org/wiki/List_of_South_Korean_films_of_2015.
To get a list of titles from that page, you would first retreive the raw wikicode of the page: https://en.wikipedia.org/w/index.php?action=raw&title=List_of_South_Korean_films_of_2015, and then run a regular expression such as /\{lang\|[^\|]+\|([^\}]+)/g on the code.
This returns a list of 149 titles.

REST API Explore: How to get same list ordered like the search on Foursquare Website?

I'm using the REST API (venues platform) to get a list of the top 5 venues per destination and category, like they are listed in the search results on the foursquare website.
For example i do the following request using the explore api endpoint:
https://api.foursquare.com/v2/venues/explore?near=zurich,CH&query=College %26 University
I'm using the apias a not authenticated. I do not pass a radius, to get the default radius.
Now the results from the api is as follows:
1. ETH Hönggerberg HIL
2. Technopark
3. Kantonsschule Stadelhofen
4. Zürcher Hochschule der Künste, Departement Musik
5. Klubschule Migros
When i search on the Foursquare Website as follow (not logged in!):
https://foursquare.com/explore?near=Zurich%2C%20CH&q=College%20%26%20University
I get the following results listed on the website:
1. SBB Digital
2. Technopark
3. ETH Hönggerberg HIL
4. EF Education First
5. Klubschule Migros
Is it possible to get the same list, as shown on the website (in the same order) also from the api? If yes? how can i do that? how do i call the api or how do i have to sort the results from the api to get the same list?
First i tried to sort the api results by the rating field, but that doesn't do the trick at all. Because in this example no one of the first 30 results does have any rating.
Thank you in advance for your help!
Greets
Tom
Make sure you are making the explore request with the same user account as on the web. Also, it looks like your queries do not match up exactly. One is "College & University and the other is "college" - try matching up the queries and seeing if the results change.
Well meanwhile i got the answer from foursquare.
The trick is very simple: just have to add the following parameters to the api call: time=any and day=any.
Then you get the results ordered exactly the same way as on the foursquare webpage (when not authenticated).
Thank you david from foursquare! :-)

Google Maps API Geocode Postal Code and set Country code?

I'm using this API call to Google Maps to get the latitude and longitude of a postal code
http://maps.googleapis.com/maps/api/geocode/json?address=2340&sensor=false
The postal code is in Australia. This API call returns locations all around the world with partial matching postal codes in the address.
Is there a parameter I can use to set the country to Australia?
Thanks
The correct way to do this is not via region biasing but rather using component filtering:
https://maps.google.com/maps/api/geocode/json
?components=country:AU|postal_code:2340
&sensor=false
Some demonstrations:
2340
93274
Please note that if you use the components parameter, you don't need to specify the address parameter.
The documentation says that Region Biasing is based on CcTLDs, which would make Australia au (haven't tried it myself).
Although it also states this:
Note that biasing only prefers results for a specific domain; if more relevant results exist outside of this domain, they may be included.

FourSquare API is giving lots of result but not the result I expect

I am using FourSquare api for searching a particular business
https://api.foursquare.com/v2/users/search?name=Spa Gregories&oauth_token=ACCESS_TOKEN
it is giving lots of result but not the result i expect. that is
Spa Gregories
2710 Via De La Valle, Ste B-270
San Diego, California 92014
when i use https://foursquare.com/search?q=Spa+Gregories&near=san+diago then i got the exact result. So is their any way to find the business according the location. I have only name and city location to use for Search. I have also checked for the venues option but it asks for longitude and latitude.
thnks
Seems you're hitting the user search endpoint instead of the venue search.
Looks like this is the one you want:
https://developer.foursquare.com/docs/venues/search.html

Twitter API: How to search only for geotagged tweets

How can I use Twitter Search API (or other) to get a list of tweets which have the "geo" param?
--EDIT--
By example: I wont get list of geotagged tweets, by #apple tag. Without location filter, worldwide.
Looks like the latest API supports that; simply use a large enough geo region for your query:
-180,-90,180,90
See more from the API link for filter and location
The streaming API allowed you to filter by a location and the search API allows you to search by geocode. You can find more information on these services on our developer resources site.
Streaming API: http://dev.twitter.com/pages/streaming_api
Example: Create a file called ‘locations’ that
contains, excluding the quotation
marks, the phrase:
“locations=-122.75,36.8,-121.75,37.8,-74,40,-73,41” then execute:
curl -d #locations
http://stream.twitter.com/1/statuses/filter.json
-uAnyTwitterUser:Password.
You will receive all geo tagged tweets
from the San Francisco and New York
City area.
Search API: http://dev.twitter.com/doc/get/search
Example: http://search.twitter.com/search.json?geocode=37.781157,-122.398720,1mi
From the Twitter API Documentation, this should be the format of your search query:
http://search.twitter.com/search.json?geocode=37.781157,-122.398720,1mi
Where 37.781157 is the latitude, -122.398720 is the longitude and 1mi is the radius to search within.
You can look for every tweet but save only the geotaged ones.
I know it dont make a lot of sense, but works quite well.
if you call you search results, you can state
for result in results:
if result.geo != None:
print result.text.encode('utf-8', errors='ignore') # or do anything you want with the tweets
Use -180,-90,180,90 to get any geotagged tweet.