With what frequency is my script calling the API? I don't want to get cut off - json

I'm using a json script from another stack overflow post and don't know with what frequency I'm calling the external data (from Seatgeek).
I don't want to get cut off from the Seatgeek api so I want to make sure I'm not going to bog down the system - I really only need the data to refresh twice a day.
I would not consider myself a developer so I'm not sure where to look. Can someone please help by taking a look at the script?

According to the Google Sheets API documentation:
Google Sheets API has a limit of 500 requests per 100 seconds per project, and 100 requests per 100 seconds per user. Limits for reads and writes are tracked separately. There is no daily usage limit.
Also, if you want to find the usage and more statistics regarding the API, you can check the Google API console and find all the information there.
For more information regarding your issue, you could check the following documentation:
[1] Google Sheets API;
[2] Google Console API Quota

Related

How many service calls am I allowed in a day?

I've set up two sets of address. One across the second row starting at B2 and another down the first column starting at A3. Using a custom function invoking google's api I am trying to get a list of drive times in minutes for all locations in the first column to all locations in the second row. I get an error stating that it has ran to many times in one day. Here is the custom function
function DriveTime(origin, destination) {
var directions = Maps.newDirectionFinder()
.setOrigin(origin)
.setDestination(destination)
.getDirections();
return directions.routes[0].legs[0].duration.value/60;
}
Error: Service invoked too many times in one day: route (line 2)
I understand the error, but how many times in one day can I make this call as a standard free user. And where can I find pricing to increase the amount of daily calls to this service?
Also if anyone knows of a way to accomplish this in less calls than I am attempting, that'd be welcomed knowledge as well.
Technically, your quota as a apps script user without API key/Billing information should be zero. But for whatever reason, Google didn't make changes to charge apps script Maps library when they changed the pricing back in June'18 for everything else related to Maps API. There seems to be a default quota, which is not explicitly mentioned in apps script documentation pages.
If you have had premium plan in the past, you can leverage Maps.setAuthentication(). But if you do not,
This method doesn't work with API keys. Additionally, please note that Premium Plan is no longer available for new customers. If you don't already have a Premium Plan license, please don't call setAuthentication(clientId, signingKey). You are able to use the Maps methods with the default quota allowances.
Which means you cannot extend the default quota allowance.
Your alternative would then be to call the maps api directlyskip oauth using urlfetchapp and parse the response using apps script vanilla javascript(es5).
You can see the pricing here.

How to add my key to this google app script?

I need to update this script to pass my key so that I don't go over the limit per day. How would I modify this script to pass my key?
(NOTE: google class information found here: https://developers.google.com/apps-script/reference/maps/geocoder)
function geo2zip(a) {
var response=Maps.newGeocoder()
.reverseGeocode(lat(a),long(a));
return response.results[0].formatted_address.split(',')[2].trim().split(' ')[1];
}
function lat(pointa) {
var response = Maps.newGeocoder()
.geocode(pointa);
return response.results[0].geometry.location.lat
}
function long(pointa) {
var response = Maps.newGeocoder()
.geocode(pointa);
return response.results[0].geometry.location.lng
}
I have never used a google apps script before.
I have this script in place and am using "=geo2zip(cell)" to call the script from my google sheet to get the zip code for incomplete addresses. There are ~28k in my sheet. I have enabled the geocoding api in my google console and my billing info. and created my key but am not sure how to include my key in the script above.
I have also tried using the following to call the api using my key. It is working, but this has resulted in VERY slow responses. At the rate it is taking these to respond, it will take me 10 days to finish updating my 28k records.
CELL M4852--> "https://maps.googleapis.com/maps/api/geocode/xml?address=ADDRESS&key=MYKEY"
NEXT CELL--> "=ImportXML(M4852,"/GeocodeResponse/result/formatted_address")"
The script responds much more quickly, so I would prefer to use that and pass my key. Please let me know if you can help.
UPDATE: I was able to resolve this using Alberto's suggestion below of adding the Maps.setAuthentication.
I believe your issue has more to do with the Google API management than with the scripts themselves. There is a way to limit how much your key is used. According to the Maps Platform documentation:
Manage Your Cost of Use
To manage your cost of use of the Google Maps
Platform APIs, you can set daily limits to all requests to any
billable API.
To view or change daily billable limits for the Geocoding API, do the
following:
Go to the Geocoding API Quotas page in the Google Cloud Platform
Console. From the projects list, select a project. In the Requests
section, on the Requests per day line, click the edit icon, then enter
the preferred total billable daily quota, up to the limit (if any)
specified by Google.
You can basically set how many requests you want to allow per day, which will avoid you going over your limit.
UPDATE
You can link the script to your account using the Maps.setAuthentication(clientId, signingKey) method, according to the docs, it:
Enables the use of an externally established Maps API for Business
account, to leverage additional quota allowances. Your client ID and
signing key can be obtained from the Google Enterprise Support Portal.
Set these values to null to go back to using the default quota
allowances.
Map Documentation Link: https://developers.google.com/apps-script/reference/maps/maps#setAuthentication(String,String)
Quotas URL: https://console.cloud.google.com/project/_/apiui/apiview/geocoding_backend/quotas?_ga=2.141719605.643331044.1560431279-1498828710.1560431279
Documentation URL: https://developers.google.com/maps/documentation/geocoding/usage-and-billing

Google Places API Web Service usage 10x as fast as requests made

I may be missing something, but the google places API indicates free usage of 150,000 requests per day (provided you enable billing). https://developers.google.com/maps/pricing-and-plans/
However, every request i place appears to be counting as "10-requests" on certain places on their website. i.e. i was capped today after making 15,000 requests. Specifically, on the billing page, it appears that each request is counted as 10. On the API Manager overview page, each request appears to be counted as 10 on the bar graph of usage, however on the response code overview it is correct. [i.e it indicates i have made 15,000 2xx Success requests within past 24-hours --- which is the case--- (and a bunch of 4xx errors, resulting from me hitting the max limit in the table...) whereas the bar graph indicates usage of 150,000].
My question is, is this a mistake, or is it the case that each request using the places API Web Services does count as 10?
There is a documented 10x multiplier on place Text Search requests:
from that documentation:
The Google Places search services share the same usage limits. However, the Text Search service is subject to a 10-times multiplier. That is, each Text Search request that you make will count as 10 requests against your quota. If you've purchased the Google Places API as part of your Google Maps APIs Premium Plan contract, the multiplier may be different. Please refer to the Google Maps APIs Premium Plan documentation for details.

Regarding Places Library for Google Maps API Quota limits

Quick question, just to clarify the wording and meaning (because it's changed a couple of times for Map loading...)
There are the two following statements in the Places API FAQs:
The Google Places API has the following query limits:
Users with an API key are allowed 1 000 requests per 24 hour period.
Users who have verified their identity through the APIs console are
allowed 100 000 requests per 24 hour period. A credit card is required
for verification, by enabling billing in the console. We ask for your
credit card purely to validate your identity. Your card will not be
charged for use of the Places API. While the lower limit is sufficient
for development and testing, we recommend enabling the higher limit
before launching your application. It is possible to request an
additional quota. If granted, the additional quota is free of charge.
If, at some stage in the future, an option becomes available to pay
for an additional quota, that quota will be over and above the
existing free quota, and you will need to sign up for it explicitly.
Note that some services may have a multiplier:
The Text Search service is subject to a 10-times multiplier. That is,
each Text Search request that you make will count as 10 requests
against your quota. The Radar Search Service is subject to a 5-times
multiplier. That is, each Radar Search request that you make will
count as 5 requests against your quota. If you've purchased the Google
Places API as part of your Maps API for Business contract, the
multiplier may be different. Please refer to the Google Maps API for
Business documentation for details.
This implies that use of the Google Places API is restricted to 100,000 queries per day, or 10,000 if you're doing a Text Search.
However, on the Uplift page, it says the following:
If you are developing a web based application that only needs to
search for places, and is not submitting new places or Place Bumps,
you should use the Places library of the Maps API rather than using
the Places API web service. The Places library assigns a quota to each
end user rather than to each key. This means that your available quota
increases with your user base rather than being capped at a fixed
amount.
I am using the Places API in the following way:
https://maps.googleapis.com/maps/api/js?key=XXX&libraries=places
...
service = new google.maps.places.PlacesService(map);
service.textSearch(request, callback);
And also for some details searching and photo searching.
Therefore my question is; Given my usage of the Places API, am I subject to the 100,000 queries limit on my app, or am I essentially uncapped at an app level, as my quota is per end-user? (i.e. per unique IP? if I had 10,000 users I have an effective quota for my entire user base of 100,000*10,000?)
EDIT:
For clarity: if I throw my API key into https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=XXXX, it will increment my Places quota count on the Google API console, however if I run queries through my JS app, I see no quota use change. I want to make sure that i'm not suddenly going to be hit with a massive quota result.
Use of the JavaScript API services, like those provided by the Places library, have quota assigned to each end-user. It's a very similar setup as objects like the google.maps.Geocoder, which has been discussed in a bit more detail in this Geocoding Strategies article.
You may apply for an uplift to the quota so that the restriction is taken away and you have unlimited access:
https://docs.google.com/forms/d/18pkOdu0uofeI8tbQoReDVfkbOIAscLvjiKc9ZP06hEM/viewform
This form is applicable to Android, IOS and Web.

Maximum limit on number of people can access a public Google spreadsheet?

I am developing an application which fetchs data from Google Spreadsheet using query.
The data comes in JSON format. I want to know whether there is any restrictions on number of request that can be sent to Google server for fetching the JSON from the spreadsheets.
I mean is there any restrictions like per hour or per day N requests.
Never seen a limit and suspect there is no such limit, but might be wrong.
Any ideas of rough volumes? I have has about 10 people at once use the service, it did slowdown a little, but was ok.
If it helps, the gdata style spreadsheet API takes about 1 Second/read and 2-10seconds/write (large sheets are slower)