-3

Excuse my breaking this out, but it's really a permissions question and not a use-case. I feel.

I found two separate threads pertaining to pulling addresses from the places api using place name, city and state here. (Retrieving location address based on place name and city in Google Spreadsheet). I tried it at the office today and it worked gloriously. I showed it to a few co-workers, but when they left and I drug the formula bar down the column of the spreadsheet I was working on, I ended up with #ERROR! (TypeError: Cannot read property "formatted_address" from undefined. (line 8). <- Refer to source script in the link above for code. I used it as written.) The error popped up not only for new addresses, but for the 80 or so I had already done. I assumed that it may have been because the pull-down would have submitted about 600 places at once and I probably went over quota.

I tried it again from home with a different account and key (as my original from the office was still returning errors and again it worked fine. I once again used a cell drag to populate the function in my spreadsheet, this time, 5 rows at a time and had the same thing happen when I reached row 76. I thought that it may be because I didn't have the places API enabled in the function or sheet, enabled the API and it looked like the issue was fixed, but it died again on row 83.

So now I'm a bit perplexed. The code and sheet are apparently fine as are my permissions, as everything that is in the sheet did work earlier, but I'm now showing an ERROR! on all of the cells that were displaying addresses not 15 minutes ago and nothing has changed aside from the fact that I tried using the same function that worked fine on rows 4-82 on row 83... which broke everything.

Is there something outside the scope of the stackoverflow suggestion and code aside from enabling the places api that I need in order to have this work for more than a short time or limited amount of records (under the 1000 record/day ceiling)?

-Scott

Script ----
function mapAddress(place, city, state) {
var API_KEY = '<My Key>';
var url = 'https://maps.googleapis.com/maps/api/place/textsearch/json?
query=' + place + ' ' + city + ' ' + state + '&key=' + API_KEY;
var response = UrlFetchApp.fetch(url);
var json = response.getContentText();
obj = JSON.parse(json);
addr = obj.results[0].formatted_address;
return addr;
}

Spreadsheet, formula tag and data.

Scott Mcgrath
  • 103
  • 1
  • 1
  • 4
  • 1
    Uhhh no, you haven't hit the usage ceiling, The Places API give you 1000 calls per 24 hour period, or if you "verify your identity" by registering a credit card with them, your first **150,000** requests per day are free. – ashleedawg Feb 13 '18 at 07:24
  • ...some (of their many) API's do have rate limits as well. I couldn't quickly find the limit for the Places API, but it's unlikely you're hitting that either. (For example the **Gmail API's limit** is ***'"no more than 250 calls per second"`***...) ([More info](https://developers.google.com/places/web-service/usage)) – ashleedawg Feb 13 '18 at 07:28
  • 2
    In order for someone to help you, you'd have to share your code and some more information about what you're trying to do, why, how far you're getting, and what you've tried. Check out "[mcve]" as well as Jon Skeets great [tips](https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/). You can always [edit] your question to provide more information. oh - and also: ***"Welcome to Stack Overflow!"*** – ashleedawg Feb 13 '18 at 07:31
  • @ashleedawg Thanks for the JonSkeet's tips. – QHarr Feb 13 '18 at 07:46
  • @QHarr -- You're welcome. It's actually kind of more like an *"S.O. Question-asking Primer"*... I figure it should be mandatory reading for all! – ashleedawg Feb 13 '18 at 08:15
  • Sorry for not including my code, but as I said, it was copied verbatim from the link, so I figured it would be a waste of bandwidth. – Scott Mcgrath Feb 13 '18 at 14:56
  • Code, query and results added. As I said in the original post, those 'Address' fields were all populated until I hit row 76, then they all broke. Adding the Places API to the project fixed them, but it broke again at line 83. Not sure of next steps. Has anyone been able to get this script to work for more than 100 records? – Scott Mcgrath Feb 13 '18 at 15:10
  • 1
    Have you verified your identity? If not, you only have 1000 requests a day BUT textsearch costs 10 requests, so you only have 100 textsearch requests a day. – Stev Feb 14 '18 at 12:03
  • Thanks, Stev !!! Thanks for being able to understand what I was asking. The 10-hits/query was eating up my 1000 calls/24 hours near-instantly. Verifying my identity kept me from hitting the ceiling before the 500 rows in my spreadsheet had been parsed. Grazi! – Scott Mcgrath Feb 15 '18 at 22:42

1 Answers1

0

Answered by Stev - The text searches I was using against the places API cost 10 hits ea., so between Geocoding and the text, I was hitting my 1000 hit limit well before 100 records had been processed. Verifying my identity and raising my useage allowance allowed me to process over 1000 records and complete the work at hand.

Scott Mcgrath
  • 103
  • 1
  • 1
  • 4