Custom Search API "Try this API" Working? - google-apis-explorer

I was trying to use the "Try this API" interface here: https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list
All I am getting from it is 400- Bad Request errors. Does this still work?

Have a look at Google's documentation on the API Explorer for background reference: https://developers.google.com/explorer-help/
There are 2 possible issues. Either you are not providing an API key, or you are not providing the Programmable Search Engine ID.
To fix the API key issue, just let Google generate one by ticking the 'API key' checkbox at the bottom under 'Credentials'.
To get the search engine ID, sign in to the Programmable Search Engine Control Panel and create a search engine. Copy the search engine ID and paste it in the cx field in the API explorer. The cx field is not optional.
Additionally, to use the standard fields, click on the Show standard parameters and enter your search terms under the q field to make a regular search query, rather than using the other search query specifications.

Related

Is there any possibility to turn off the Places API in the Google Cloud Console and not get an error?

is there any possibility to turn off the Places API in the Google Cloud Console and not get an error while the customers write a query into the address field? We do not want to use any of the Places API features including Autocomplete so we decided to turn it off, but now if anyone starts typing into the address field gets an error message. Thank you for your response in advance.
No, you need Google's Places API enabled on your project to be able to use any of its services (such as Place Autocomplete). Otherwise you'll get errors as you mentioned.
If you turned it off due to costs, note that there are ways to lower them (check my answer here).
If you want to turn it off for good and allow users to type their address into a text field that doesn't use Google's Autocomplete widget (and hence not get errors), then you'll need to locate and remove your Maps API script and/or your Autocomplete implementation from your source code.
E.g. see the below example code which creates an Autocomplete object and attaches it to an input element.
<input id="autocomplete"
placeholder="Enter your address"
type="text"/>
var autocomplete = new google.maps.places.Autocomplete(document.getElementById('autocomplete'));
Hope this helps!

How do I get a direct link to a place on google maps with the Place Id

I have the Place Id of a place on google maps in my app. Is there a way to put the place Id in a URL and have it directly link to the page? Or does it have to be done through the URL?
I can't seem to find anything detailing this in the docs. I've tried below, but it just gets me the standard google maps page:
https://maps.google.com/maps?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4
Recently, in May 2017, Google launched the new Google Maps URLs API. You can read about this API in the official documentation
https://developers.google.com/maps/documentation/urls/guide
So, from now on you can construct a URL for Google Maps using the place ID. In your particular case this URL will be
https://www.google.com/maps/search/?api=1&query=Google&query_place_id=ChIJN1t_tDeuEmsRUsoyG83frY4
Hope this helps!
Not directly, using the placeID you can get a variety of information in JSON or XML format, among them there are also the lat lng of the place and its address with which you can easily locate the map
google developer doc
The URL for a specific Google Place is returned by the places details API endpoint.
If for example you query:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJV2BQ4laeekgRFauLvdXbFXE&key=YOUR_API_KEY
You will see that in the returned JSON there is a key 'url' which points to https://maps.google.com/?cid=8148660811851344661
The correct format, at this time, to produce a general link that goes directly to correct google place is: https://maps.google.com/?cid=[place_id]&t=[maptype]
The map type parameter "t" is apparently necessary. Without it, google maps seems to perform a more general search when the link opens that is sometimes successful and sometimes not. With it, maps opens to correct place each time whether it opens in browser or in app on mobile.
Set this parameter to "m" for a street map and "k" for a satellite map.
A lot of answers on SO show the following syntax which often pulls unwanted results if two locations of the same name are nearby e.g.:
https://www.google.com/maps/place/Starbucks/#43.088554,-88.06579,17z/
If you are already using google places api, then you have the place_id, so i recommend using it to avoid ambiguity.

How are built the search parameters in the url of a Drive search

When I search something using the standard Drive interface, the resulting page have an url which encodes the search terms, for example (basic search):
https://drive.google.com/a/mydomain.com/?tab=mo#search/toner
or, as an alternative:
https://drive.google.com/a/mydomain.com/?tab=mo#advanced-search?q=fogna&view=2&visibility=2
Where can I find a reference on how this url is built (query parameter syntax)?
I understood the following empyrical;
"?tab=mo" seems somehow required
"visibility=2 searches all the documents in my domain (for Business Apps)
"advanced-search?q=" is alternative to basic search
"view=2" or "view=1" seem the same thing
I haven't experimented different combinations until now.
I am trying to integrate a custom search box in one of our Sites, in order to provide the user with results from the Drive contents (this is not possible using the standard search function in sites).
Unfortunately I can't answer your question but I can share that I'm looking for exactly the same thing. Since Google retired iGoogle the built in Google Docs/Drive search gadget within Google sites no longer returns a result. Creating a dialogue box that returns a custom URL for search would be the most straight forward method to perform a basic search.
It seems that as a minimum the base URL for a search is ...
https://drive.google.com/a/mydomain.com/#search/
Appending the search term requires %20 to replace spaces
e.g.
https://drive.google.com/a/mydomain.com/#search/my%20document will return a search for 'my document'
Good luck Massimo, hopefully some can assist

Is there an OR operator on google place API?

I am using this api call with &keyword= and I want to have multiple words in the keyword but OR them. I have tried OR and | but it seems to ignore it. example here
Is it possible to OR keyword in a google places search
The Google Places API does not current support multiple keywords or names in requests. A Places API - Feature Request for this has been filed here.
If you believe this would be a useful feature please make sure your star the request to let us know you are interested in seeing it added.

Google Places Autocomplete API flow

I want to use Google Places Autocomplete API to provide search-while-typing for an Android app.
the Autocomplete API returns IDs and References, requiring an iteration through the results to get the details (such as name and geometry) for each place, this is slow and results in a bad user experience. also, many API calls are done for each key press.
is there a better way to provide such searching capability with Google Places ?
Is there a reason you need to have the geometry for each possible autocomplete place after each keypress of the API? Showing this seems like generally it would not be a great user experience, and is not what the Autocomplete API was designed for.
In theory the name (description) should be enough for the user to decide which item they're interested in, and then after a user has actually selected something you can request additional details as needed.
On the other hand if you already have some information about the name of the place, you could use the Places API (not Autocomplete) to get additional details of matching nearby places:
https://developers.google.com/maps/documentation/places/#PlaceSearchResponses