(CAUTION) Unexpected High Bill Amount When Using googlemaps in Python

I am really grateful that I have the warmest support from my advisor and friends during this hard time.
最下方有本文的“马保国全文背诵版”,感谢阿Q精神,差点丢了1w3,但是没失去快乐。(You can find the Chinese version of my experience for fun.)

To be frank, I think the subtitle of this blog is supposed to be “How to burn 13 thousands with one line and get your money back”.

Last month, I had to deal with a large list of addresses and geocode them to latitude and longitude. To complete all transformation in hand is almost impossible. So it is natural that using map API to solve this issue. There is no doubt Google Maps performs the best on processing address in English. And I found it offers an official python toolkit googlemaps, which can saves lots of time.

Before turning on two APIs required by googlemaps, “Places API” and “Geocoding API”, I also checked the pricing plan of Google Maps Platform. Google Maps Platform uses a pay-as-you-go pricing model. Users can request basic data for free and the price of geocoding is not quite expensive (no more than 5 USD per 1000 requests).

After reading several tutorials about Google Maps Platform, I finally chose to use the python function suggested by DHogan[2], and my code can be found in this blog[1]. However, geocoding the address by text_search function in googlemaps is fairly expensive (Price of text_search), especially the prerequisite “Places API” costs tenfold as “Geocoding API” does.

In that “black sunday afternoon”, I started requesting loops with pleasure and had a cheerful dinner. Everything went well until I received the payment notification from my credit card bank. Although I shut the program down as soon as possible, these few lines of codes had cost my 13 thousand bucks…

Total Cost

So,

  • PLEASE CHECK THE PRICE OF EACH LINE IN YOUR CODE WHEN USING PAID APIs.
  • SET REQUEST LIMIT FOR YOUR APIs AVOIDING FATAL ATTACKS.
  • SET CONSUMPTION LIMIT FOR EVERY PAY-AS-YOU-GO ACCOUNT.

Fortunately, the experience of another GMP user gave me hope.[3] (Sincere thanks to CHENG ZHENG) I contacted GMP team immediately by both phone call and email. Here is the flow of GMP support for my issue.

Flow of GMP Support

GMP provides 3 ways for users to get support from platform.

  • Chat: Haven’t tried. But chat support in billing section is paid service.
  • Phone call: GMP team will create a new case for you and contact you through email too. (Later than directly submitting the case through email.)
  • Email: Reponsive and supportive!

GMP Support Page

I reported my case on support page and chose to communicate with GMP Team by “email”. I can not find the case description any more. But, for reference, I emphasized three key points, which were also proposed in feedback survey:

  1. The prices of functions in official toolkit googlemaps are not clear and transparent enough.

  2. The cost of prerequisite ‘Places API’ is unexpected, since user only takes the geocoding services.

  3. The consumption nofication is delayed, and user can hardly stop the program or request in time.
    Payment Notification

However, I have to say that GMP team took actions promptly and gave me genial helps. I list all emails between GMP and me below.

From billing team:
Email1
My reply to billing team
Email2
From tech team (including the tutorial for restricting API key and setting daily request limits):
Email3
My answers to tech team’s questions:
Email4
From tech team (accidental usage spike is validated and the tutorial for shutting down project ):
Email5
My reply:
Email6
My question about shutting my project down:
Email7
Answers from tech team:
Email8
From billing team:
Email9
My reply:
Email10
From billing team (transferring my adjustment request to internal team):
THIS ADJUSTMENT IS ONE TIME COURTESY
Email11
My reply:
Email12
The adjustment request is approved:
Email13
Some further questions:
Email14

GMP COMPLETES THE ADJUSTMENT IN DEC 3!!!
I noticed that good news several days later.
Adjustment

At last, I really appreciate the assistance from GMP team. We all should know that the adjustment is only one-time-courtesy and the future charge will be counted as valid.

PLEASE BE CAUTIOUS WHEN YOU ENABLE EVERY PAID APIs!


Thanks to ‘one of the best’ standup comedian, Master MA Baoguo, I got over from losing 13 thousands HKD, and encouraged myself to deal with the mess.

Here is the MA Baoguo version of this story in Chinese, just have fun!

朋友们好啊我是BUG代码烧钱门掌门人。

刚才有个朋友问我周老师发生甚么事了,我说怎么回事?给我发了几张截图。我一看,噢!原来是昨天,有两个API,都是Google的,一个Places API,一个Geocoding API。

塔们说,诶…有一个说,“如果你要英文地址转码,转换成经纬度,周老师你能不能用用我这个toolkit?诶…可以搜索出老师你要的信息。”

我说可以,但是我说你这个文档,不好用,他不服气。我说小朋友你能不能让我一行代码直接完成转换,他做不到。他说“你这也没用”,我说我这个有用。

这是面向CV工程师(ctrl+c/v),传统功夫是讲CV的,四两拨千斤,体重200多斤的英国大力士都写不动我这一行,啊…他说要和我试试,我说可以。

诶…我一说,他“啪”就站起来了。很快啊!然后上来就是一个账户注册,一个信用卡关联,一个端口默认开启。

我全部防出去了啊。防出去以后自然是传统功夫以点到为止,把包调了出来,只做了几次调试。我笑一下,准备收手。

他也承认我是正常调用。他承认我按照文档调试的,啊!我吃饭的时间打算不调用了,他突然能循环跑起来,啊,我大E了啊,没有闪。

诶…他的默认开的那个信用卡。信用卡扣了一千,但没关系啊。他也说啊,他截图也说了,我流眼泪了,捂着眼,我说婷婷,我给程序停了。结果一晚上以后,又欠了一万。

我说小伙子你不讲武德你不懂,他忙说, “周老师对不起,我不懂规矩,啊,我是…” 他说他是乱打的。

他可不是乱打的啊,注册连卡开端口训练有素,后来他说他有三四页不同的Price文档,Basic Data免费和toolkit又不是一回事。啊,看来是有备而来。

这两个年轻人,不讲武德,

来,跑!

来,偷袭!

我2*岁的老同志。这好吗?这不好。

我劝这位年轻人,耗子尾汁,好好反思。以后不要再犯这样的聪明,小聪明,啊。Coding Dog要以和为贵,要讲武德,不要搞窝里斗。

谢谢朋友们!


(CAUTION) Unexpected High Bill Amount When Using googlemaps in Python
http://arwenzhou.github.io/2020/12/08/Python-How-to-burn-13-thousand-with-one-line/
Author
Arwen
Posted on
December 8, 2020
Licensed under