Python client library for Ola Maps API Web Services
Project description
OLA Maps Python Package
A Python wrapper for the OLA Maps API, providing easy-to-use abstractions for developers.
Supported APIs
- Autocomplete
- Geocoding
- Reverse geocoding
- Directions
Usage
Installation
Install the package using pip:
pip install olamaps
Authentication
There are two ways to authenticate:
-
Using API key
os.environ["OLAMAPS_API_KEY"] = "your_api_key" # OR client = Client(api_key="your_api_key")
-
Or using
client_id
andclient_secret
os.environ["OLAMAPS_CLIENT_ID"] = "your_client_id" os.environ["OLAMAPS_CLIENT_SECRET"] = "your_client_secret" # OR client = Client(client_id="your_client_id", client_secret="your_client_secret")
Follow the same steps for AsyncClient as well.
Client
from olamaps import Client
# Initialize the client
client = Client()
# Autocomplete a query
results = client.autocomplete("Kempe")
# Geocode an address
results = client.geocode("MG Road, Bangalore")
# Reverse geocode a latitude-longitude pair
results = client.reverse_geocode(lat="12.9519408", lng="77.6381845")
# Get directions from one place to another
results = client.directions(
origin="12.993103152916301,77.54332622119354",
destination="12.972006793201695,77.5800850011884",
)
# close the client
client.close()
Or you can use the context manager, in which case you don't need to close the client manually:
with Client() as client:
results = client.autocomplete("Kempe")
AsyncClient
Usage is very similar to Client, except that all methods are coroutines:
# use await for all methods
results = await client.autocomplete("Kempe")
# use await for closing the client
await client.close()
Also the context manager is async:
async with AsyncClient() as client:
results = await client.autocomplete("Kempe")
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
This project is not officially associated with or endorsed by OLA. Use of the OLA Maps API is subject to OLA's terms of service.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file olamaps-0.5.1.tar.gz
.
File metadata
- Download URL: olamaps-0.5.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba0ae1d97e4f016f6ee51465b0aec96e493a6bc49f481d60bb6801de8bfa1d9d |
|
MD5 | 2f9be8afc8d5144f57686b9d0357973b |
|
BLAKE2b-256 | 5ac50380951016b79d83661ac60524c31c6f555953ceac61c62654b9c870a2a4 |
File details
Details for the file olamaps-0.5.1-py3-none-any.whl
.
File metadata
- Download URL: olamaps-0.5.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4315c1376585ee860e60bb888b264c61c4e42a444fbecd35095bbc03a55cae2c |
|
MD5 | 3509de20144b9980624a21ecd9a37a3e |
|
BLAKE2b-256 | ad9ebe70ee704699806c21b6c327409de68bdaa1ab476aa1e9f495ad883d4ab3 |