Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapbox API Limits #4

Open
brandonfancher opened this issue Jan 12, 2018 · 1 comment
Open

Mapbox API Limits #4

brandonfancher opened this issue Jan 12, 2018 · 1 comment
Assignees

Comments

@brandonfancher
Copy link
Owner

Mapbox is turning off their deprecated Distance API on January 15, 2018. To ensure the application continues working, we must use their Matrix API instead. We have switched to this in PR #3.

This may prove problematic. The Matrix API's free tier includes 50,000 API calls per month. Each nearest-station query uses up 16 of these calls. (It was 16 x 16 before I optimized it to include the user's location as the only source!) Still, this allows for only around 104 nearest-station queries per day, across all our users. This will likely not be enough.

Additional API calls cost $0.50 per 1,000. That could add up quickly. I don't currently have a payment method on file with Mapbox, so when we near our limit, we'll get a warning. When we exceed it, we'll get a 10-day grace period before they shut us off.

As for alternatives, the Google Distance Matrix API has a monthly free-tier cap of 75,000 API calls. That's a modest increase, but it's not a viable solution at all; their T&C forbid it being used when displaying another map provider's map.

So, we may need to entertain various options, including, but not limited to:

  • Programmatically find the 3 or 4 nearest stations as-the-crow-flies, and only include those in our Mapbox Distance Matrix API request. (This is probably the best option.)
  • Find another distance matrix API
  • Pay for any additional overage out-of-pocket
  • If overage is modest, collect donations?
  • Charge for the application?
  • Reach out to developers in the community that might want to help? For example, we could link to their apps from ours (I'm thinking maybe apps that are providing ticketing services?)

We may have to get creative.

@brandonfancher
Copy link
Owner Author

Version 2.1 (see PR #7) optimizes Mapbox API usage by getting the nearest three stations as the crow flies and sending only those to the Mapbox Matrix API. This should reduce usage five fold.

According to my calculations, this still may not be enough to keep us under the free tier. So we'll need to keep tabs on that. My payment information is now in Mapbox, so it won't shut us down...but it will charge me for any overage.

Furthermore, when the light rail extension opens in March, we will likely see a big influx of users. This also could bump us over the free 50,000 requests (even though we'll still only be sending three stations to the Mapbox Matrix API.)

Another option would be to stop showing travel time to the station, and default their app to the nearest station as the crow flies. In that case, we'd remove the Walking/Driving toggle too.

Honestly, though, I'd love to be able to keep the travel time with the Matrix API and introduce calculations that take traffic into consideration. Mapbox now offers that, but it increases API usage.

We'll need to see post Jan 26 what our numbers are looking like. Maybe they'll show that there's some other inefficiency that we haven't identified yet...maybe the app polls their API too often or something. IDK.

Keep tabs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant