python-overpy
python-overpy copied to clipboard
Support for Overpass API /api/status
Issue type
- Feature Idea
OverPy version
0.4
OS
- Windows 7
Python version
- Python 3.6
Summary
It is possible to encounter several HTTP errors when using the Overpass API, relating to the status of a user's queries. For experienced users, helpful information is available regarding these errors from /api/status. The ability to catch and access the information from /api/status
would be beneficial to users trying to make a significant number of queries while respecting the rules of the Overpass servers.
Expected results
Something like the following would be expected:
query_string = ('way["highway"~"."](around:20,{},{},);out;').format(lat, lon)
while True:
try:
result = api.query(query_string)
break
except (overpy.exception.AnyOverpassError):
print(result.api_status)
Which gives some output:
'Connected as: 2557965506
Current time: 2017-05-01T16:17:38Z
Rate limit: 2
2 slots available now.
Currently running queries (pid, space limit, time limit, start time):'
As found on the /api/status
site.
This would allow users to see information like rate limit and available slots, and adjust the code to respect the status of the server.