I am attempting to write a program in Python that get a list of changes in the Google Drive API.
I've noticed success in this by using v2 of the API but not for v3 of the API.
The reason being v3 requires a page token. According the Google Drive API documentation, this is used for acquiring a list of future changes. This means that you cannot get previous changes unless you have a prior page token.
In v2 the page token is not required and therefore I can exclude the page token in the API call and get a list of all changes (which is what I want).
Is there a way that I can get the first page token so that I can get all changes in v3? Is there another way around this?
If your main goal is to get a list of all changes inside a drive, you can do it very easily with the Changes.list() method. If you want to list the changes of your main drive, you only have to leave the driveId parameter blank.
UPDATE
Alternatively you could use the method changes.getStartPageToken. That method returns the token that will be used for the next change. So you only need to subtract 1 to that token to know the actual page number. Then you can interact from 1 to that number to have a full list of pages.
Related
I have a few Google Map locations added at my business.google.com account.
I'm trying to find a way to request all of them from my account; to include them in my website.
I've already signed up for my API key, and added my trusted domain, but I haven't found a way to request all of them with the API without already knowing either their locations or place ID.
My goal here is to manage only one list at Google account to keep them updated. I don't want double-management, adding and editing them both at my Google account and my website database.
I've figured out that I can download my locations as cvs file, that could be then uploaded to my website database when a location is edited or updated. But is there any way to request a json with them directly with the javascript API from within my website domain in one ajax request?
E.g. 'https://maps.googleapis.com/maps/api/place/details/json?key=MY-KEY&someOtherParam=toGetThemAll'
Thanks in advance
You can look into Google My Business API:
https://developers.google.com/my-business/content/prereqs
There is a REST endpoint to get a list of locations related to one account:
https://developers.google.com/my-business/reference/rest/v3/accounts.locations/list
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.
I understand the usage limits for the Google places API.
However, once you have made a place details request, occasionally a location will have several photos available to it.
You can then retrieve the URL for these photos by using the following function:
photo.getUrl(maxWidth:200,maxHeight:200);
This works find and the actual URL of the image is returned. No ajax request appears to be made to Googles API, it simply returns a URL which you can then dynamically add to your DOM.
The URL's returned are like so:
https://lh4.googleusercontent.com/-SG8x8m7avHc/UWm8kgkkKTI/AAAAAAAAAA8/6_wM5YoSnlk/w1280-h1280-s0/2013-04-13
What I need to know is if accessing these images has any kind of usage limit attached to it.
Does each view count as one Google Places API request? Or are all views essentially free and it is only the initial Place details request which counts towards usage.
I know this question is old but it still isn't answered, so I'll try my best.
Does accessing these images have any kind of usage limit attached to it?
No, once you've successfully requested a place result using the Places API you are free to request as many image URLs relating to that result as you'd like with no usage limitations on the Places API itself.
However, Google will limit the number of images you may receive if you don't have a premium plan. So for instance, if you were to make 200 image URL requests for 'The Eiffel Tower', you might only receive up to 15 (or less) images if you're on a free plan. I know that sucks right.
Does each view count as one Google Places API request? Or are all views essentially free and it is only the initial Place details request which counts towards usage
If you're referring to image URL requests as a "view". Then the latter is true. Each image source requested won't increment the usage of the API.
If you're still uncertain here's a link to the Place Photo requests method in the Google Maps Places API Documentation
Each page of results must be displayed before displaying the next page of results. Note that each search counts as a single request against your usage limits.
refer here
The closest thing I can get are events that show a "COLLAB_ADD_COLLABORATOR" type of event - however, this does not include the collaborator's identity.
Note that I want this information potentially before this user does anything to a file or folder: I simply want to get a list of all collaborators whether or not they have performed any actions.
You can use V1 of the API to fetch the collabs of each folder individually. This might not full-fill your requirement of knowing before the collab does anything on it. But this is your best bet right now. V2 doesnot have it yet
http://developers.box.net/w/page/12923933/ApiFunction_get_collaborations
That information would be contained in a v2 'collaborations' object. The /collaborations endpoint currently isn't implemented for the v2 API. However, it will be implemented before v2 is GA.
I have seen the two forms of reference to the Google Places Library/Service, using JavaScript vs calling the API directly, a number of times, but I don't understand the difference. The Google Docs don't describe anything about two methods of accessing the API.
For example, this question talks about 2 ways of accessing the API: OVER_QUERY_LIMIT in a loop
And it appears that there is some type of direct web access taking place in this question: Querying Google Places API using jQuery
Is this something where there was an old way that involved formatting URL parameters and the new way is by utilizing the JavaScript library calls?
FINAL SUMMARY EDIT: There are two distinct ways of requesting data from Google, as described in #Dan Nissenbaum's answer below. And since my original question, the QUERY_LIMIT question referenced above has been edited to also include more information about the two options.
Perhaps you are referring to the distinction between the Google Places API that is intended for use on the SERVER (i.e., utilizing PHP to call the Google Places API directly), and using the completely different approach of the Google Places Javascript Library in which the BROWSER executes Javascript using the Javascript library provided by Google (that internally wraps calls to the Google Places API, so that you, as a Javascript programmer, only need to understand the Javascript library provided by Google, and use that)?
Here are the two scenarios.
Scenario #1: Use the API directly. For this method, you must refer to Google's API documentation for the Google Places API: https://developers.google.com/maps/documentation/places/.
Using this API works as follows (giving a simple example only). Say you want to retrieve places within 1000 meters of latitude=-27.2531166, longitude=138.8655664. You need to hit a URL as described by the API documentation: https://developers.google.com/maps/documentation/places/#PlaceSearchRequests.
In this example, the URL looks like this (it's long):
https://maps.googleapis.com/maps/api/place/search/json?location=-27.2531166,138.8655664&radius=1000&sensor=false&key=AddYourOwnKeyHere
You need a key for your personal use, which I assume you have. There are other options you can specify, such as limiting the results to restaurants, etc.
When you hit this URL, the data will be returned in either JSON, or XML format, as specified by the text json in the URL above (use the text xml for xml). This data is returned exactly like data is returned from any URL call when you hit a URL in your browser.
You can test this by simply typing the URL directly in your browser, and see the results.
To use the API directly from code, you will need to use code that hits the external URL above within code and retrieves the results within code (for example, using the PHP CURL library, or using AJAX in Javascript).
Scenario #2: You use the Javascript library that Google provides that wraps the API, so you don't need to deal with it. I'll update the answer with more details about this, if you don't know what this is.
The docs do discuss the two different approaches. The Places Library utilizes the Google Places services from within the JavaScript Google Maps API. If you are using the Google Maps API in a browser, this is probably the approach for you:
https://developers.google.com/maps/documentation/javascript/places
There is also a web service, which allows you to query directly from your application. You query it using direct http calls to Google services. If you need access to the data on your server or a mobile device, this is the approach you want to take:
https://developers.google.com/maps/documentation/places