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

OpenCage status codes #477

Closed
reinososamanta opened this issue Mar 17, 2021 · 4 comments · Fixed by #479
Closed

OpenCage status codes #477

reinososamanta opened this issue Mar 17, 2021 · 4 comments · Fixed by #479
Milestone

Comments

@reinososamanta
Copy link

Hi,

According to the OpenCage documentation https://opencagedata.com/api#codes, code 429 corresponds to "Too many requests (too quickly, rate limiting)" while code 402 corresponds to "Valid request but quota exceeded (payment required)".

Geopy raises the following error when receiving code 429:

raise GeocoderQuotaExceeded(
                'The given key has gone over the requests limit in the 24'
                ' hour period or has submitted too many requests in too'
                ' short a period of time.'
            )

if status_code == 429:

However, code 402 is not handled, the one linked to "The given key has gone over the requests limit in the 24 hour period", which should actually correspond to exception GeocoderQuotaExceeded, while code 429 should be associated with another type of exception, since it should be possible to retry after some backoff time.

Is this something that could be handled? :)
Thank you!

@KostyaEsmukov KostyaEsmukov added this to the 2.2 milestone Mar 20, 2021
@KostyaEsmukov
Copy link
Member

It is a fair note that 402 should be handled differently, and I agree with that.

However, the two cases "no money on account" and "too many requests for a period of time" are currently not separated in geopy, and both are expected to be raised as GeocoderQuotaExceeded.

I see how that difference might be useful, so I guess we could introduce a new GeocoderRateLimited error, which would extend the GeocoderQuotaExceeded class (for backwards compatibility).

Would that be acceptable for you?

@reinososamanta
Copy link
Author

Hi,

That would be perfect :)

Thanks! :)

@KostyaEsmukov
Copy link
Member

Fixed in #479, will be released as geopy 2.2.

402 should now be raised as a GeocoderQuotaExceeded error, and 429 as a new GeocoderRateLimited one.

@reinososamanta
Copy link
Author

Fantastic! Thanks a lot :)

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

Successfully merging a pull request may close this issue.

2 participants