Itβs time for a Failure Friday, one of my many F-ups! π This time a story about how we maxed out a credit card π€ by not capping the google API usage.
This happened while creating Attentionflow.ai, a service that generates game previews and reviews using sport statistics and event data. ππ
We had a bright idea π‘Letβs add weather data! Did the players battle it out in a downpour β or bask in the sunshine? βοΈ
To get that info, we combined three APIs;
- A sports API ποΈ
- Googleβs Geolocation API π
- A free weather API π€οΈ
The first API gave us the date and venue. Googleβs Geolocation API gave us the latitude and longitude of that location which was needed as input for the weather API, which gave us the weather data.
And β boom π₯ β we had weather forecasts in all our reports!
And very soon we had a maxed out credit card. π³π²
The mistakes: Our code had checked the location of every stadium in the world every 5 minutes, and also checked, and re-checked, and re-checked again the latitude and longitude of each of those locations. πβ±οΈ
Google had, dutifully, charged us for every. single. request. πΈ
Of course, we should have had endless cache on the data retrieved. Stadiums very seldom move to a new address. ποΈβ‘οΈπ That was a fail number one.
However, those whoopsies can happen when you are trying to push out new features at a high pace. π
The real lesson learned, for me at least, was to always make sure you have a cap on API usage.
All in all, it cost us β¬1,000. Money that could have been better spent elsewhere. Literally anything else would have been better.
But at the time I was super happy we had not used the other credit card that had a 25K spend limit. π
The image above is not from our API usage, itβs from another insane growth.