Bing API: specify both medium and large images - bing-api

I am forming a JSON request to pull images from the Bing API for a given query. I want to get both medium and large images (exclude small). I tried using:
Image.Filters=Style:Photo+Size:Medium
But this seems to be "and"ing them, as I get no results. Having only one of them works fine.
How do I "or" them?

&Image.Filters=Style:Photo&Image.Filters=Size:Medium

Related

How to search for locations using Tags inside OpenStreetMap

Using the Nominatim APIs, am able to do a search based on a query. However, all the results returned have a Tag associated with them, like leisure=fitness_centre.
How can I, thus, use the OpenStreetMap APIs to search a given location (say London) for all the fitness_centre tags? Idea is to be able to search the map, zero in a location (say London, Oxford etc.) and then search for all places/locations with Tag [leisure=fitness_centre]
Using Google Places API, one can search using tags using something like below (specifying type=gym) -
https://maps.googleapis.com/maps/api/place/search/json?location=51.509865,-0.118092&radius=50000&sensor=true&key=&types=gym
Only issue with the Google Places API is that they are extremely pricey!!, so looking for OpenStreetMap as an alternative.
For searching specific objects in OSM, Overpass API is usually a good choice.
There is a nice frontend available called overpass turbo. Open the wizard, enter "leisure=fitness_centre in London" and it will generate an appropriate query:
[out:json][timeout:25];
{{geocodeArea:London}}->.searchArea;
(
node["leisure"="fitness_centre"](area.searchArea);
way["leisure"="fitness_centre"](area.searchArea);
relation["leisure"="fitness_centre"](area.searchArea);
);
out body;
>;
out skel qt;
Then hit run to see the results on the map: https://overpass-turbo.eu/s/1fbg
Please note that the {{geocodeArea:London}}->.searchArea; part is a feature added by the overpass turbo frontend. Overpass API won't understand this geocoding request. Instead, you have to replace it with an area query and the corresponding relation ID (in this case area(id:3600065606)->.searchArea;).
Another thing to note is that Overpass API servers shouldn't be used for heavy queries or commercial purposes. If you need this kind of service then install your own Overpass API instance or use a commercial Overpass API provider.

Google Place API for airports

I have a requirement to show airports close to a particular lat/long with a specific radius. For that, I used google search nearby APIs below.
My problem is that I want to get only airport info but the problem is the API is fetching helipad too. How I can be more specific? Query URL :
https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=keyVal&location=lat,long&radius=10000&type=airport
Is there any way to filter the results to get airports only from the above ?
I believe that's how this endpoint works. But there is always a way to filter results as per your requirement. I can help more if you provide the how the response JSON looks like.

Retrieve images from Instagram that contains more tag

I'm retrieving images from Instagram but I can't figure out why with this call:
https://api.instagram.com/v1/tags/trytag/media/recent?access_token=ACCESS_TOKEN
I can only retrieve images with one single trytag.
So if I post an image with more tags the link above can't retrieve it.
The current Instagram v1.0 API doesn't currently allow for multiple tag search. You could query for each tag separately and combine your results, or an alternative is to use a third party search like Mixagram, which is most likely doing the same thing but doesn't require an enormous amount of storage space upfront.

Google Custom Search API returning HTML documents instead of images

I started using the Google Custom Search API for a project, the idea is to search for images, and I wanted to use the Custom Search because the Google Images API is deprecated.
I already enabled image search on the CSE console
My query is like this:
https://www.googleapis.com/customsearch/v1?key=APIKEY&cx=CSECX&q=flower&alt=json&searchType=image&num=1&start=NUMBER
Where NUMBER is a random value between 1 and 20
Sometimes, it returns results like this:
{u'kind': u'customsearch#result', u'title': u'Flower Wallpaper Tumblr #6790199', u'displayLink': u'7-themes.com', u'htmlTitle': u'<b>Flower</b> Wallpaper Tumblr #6790199', u'snippet': u'Flower Wallpaper Tumblr', u'htmlSnippet': u'<b>Flower</b> Wallpaper Tumblr', u'link': u'http://7-themes.com/data_images/out/7/6790199-flower-wallpaper-tumblr.jpg', u'mime': u'image/jpeg', u'image': {u'thumbnailWidth': 150, u'byteSize': 808360, u'height': 1200, u'width': 1920, u'contextLink': u'http://7-themes.com/6790199-flower-wallpaper-tumblr.html', u'thumbnailLink': u'https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSad0z_Wla0nRHAcQrjO5jLQkFjcoqnNHhejjuGmdA1AW2BqIVEpLARAk0s', u'thumbnailHeight': 94}}
Highlighting the interesting part:
u'link': u'http://7-themes.com/data_images/out/7/6790199-flower-wallpaper-tumblr.jpg', u'mime': u'image/jpeg'
So it seems that the URL is http://7-themes.com/data_images/out/7/6790199-flower-wallpaper-tumblr.jpg and mimetype is image/jpeg, but if you go to the URL, you'll see it's not an image, but an HTML document
Of course, I could capture this as an exception, but I don't want to waste daily API requests (out of a 100 limit per day) because the API didn't give me an image when I explicitly said so.
So, the question is: Is this normal behaviour, or misconfiguration/misuse on my part? If so, how could I fix it?
Thanks for your attention
After a little bit of reading, my best guess is that some servers are doing a resource redirect to prevent external sources from hotlinking directly to a resource. The file in question is advertised as an image, but accessing it from an external server will provide an HTML document instead. This is not a URL redirect, so it isn't detected by clients (including the Google crawler) until the resource is downloaded.
This sort of resource redirect is done on Apache servers using the .htaccess file and the RewriteEngine, with a technique similar to the one described here, although that particular technique can't be used to bait-and-switch images for HTML documents.
In short, if a server is lying about what type of file it's hosting, Google can't do anything about that. You can confirm that this is not an issue with the custom search API by performing the same query on the normal web search interface -- notice that clicking the image loads an HTML document rather than the image itself.

How to get city sights images from Google Places API

I use Google Places Photos Api and I want to get sights images for selected city by placeid or city title.
I try 2 methods:
1. f.e. I send request (used London placeid)
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJdd4hrwug2EcRmSrV3Vo6llI&key=API_KEY
get location from response
"lat": 51.5073509
"lng": -0.1277583
next step is request to
https://maps.googleapis.com/maps/api/place/radarsearch/json?location=51.5073509,-0.1277583&radius=5000&types=park|church|cafe|food|bar|night_club|stadium|store&keyword=&key=API_KEY
response contain many objects with placeid, that i use for new request like first
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJ1eu1vwgIdkgRwjsifpZERQc&key=API_KEY
response contain photo_reference object which is the part of my image source
https://maps.googleapis.com/maps/api/place/photo?photoreference=CoQBcwAAAMLCk4X_WMliqIfISe-mgxRadycuzApodVcaCrTMGP6wQXJaquATedXMkvnjuLAfTG9xzBYQfSNm3iXV07wxHr_X_WDhfjz_yQjmqCYlKwYwK5hH-nl9qi-4ZZqKKtFuphFEY8ka25GYN2sTNMdd0v99j7YCzpR-lHJnl0zA9QoPEhBA5CnCgElBAU7Z92VTShg2GhQUes4fTRKiJlW6rYKYEaNilauWaA&key=API_KEY&maxwidth=1200
result image
It's not the best photo of London...
2.
Using textsearch with param query=sights+in+London
https://maps.googleapis.com/maps/api/place/textsearch/json?query=sights+in+London&key=API_KEY
This request return response which are contains photo_reference objects.
finally request is
https://maps.googleapis.com/maps/api/place/photo?photoreference=CnRnAAAAlLsg47UJRPVLdM8_sUbeLSia70EJ_mTisVDfCDTVUYNXl-35BGqzRARtq-Lt1CNcBWy3sKigfBVuF0iCr9-xqp1khK2l5JV3806LKvZrHJCaONYW35UBxxIIwxvxV-df4I4hg6f_zgeeIkWXGSYQhhIQNGYJl0fvHb3HslymbhH1thoUdLhGe8rJVCnyl_y0xAagzkFWs-Y&key=API_KEY&maxwidth=1200
result image
How can i get images like these
The Places API directly returns some photos for cities like London now. For example your query for London by Place ID:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJdd4hrwug2EcRmSrV3Vo6llI&key=API_KEY
Includes this photo of the Place of Westminster that is also shown on Google Maps.
It looks like you'd be looking for an API that surfaces Google Image Search results, and there is one: Google Custom Search
https://developers.google.com/custom-search/docs/overview
I'm not familiar with it, but there's already an answer for how to get just images out of your requests to this API:
Google custom search for images only

Resources