Skip to main content

Python client library for Ola Maps API Services

Project description

Ola Maps Python API Wrapper Library (Unofficial)

Package version Downloads

The Ola Maps Python library provides convenient access to the Ola Maps API from any Python 3.9+ application. The library currently includes type definitions for Routing APIs, Places APIs and Maps Tiles.

Installation

# install from PyPI
pip install py_olamaps

Generate API Key

Follow the official documentation of Ola Maps to generate the API Key. We will soon publish a documentation from our end.

Usage

  1. Routing APIs
    1. Directions API
  2. Places APIs
    1. Autocomplete API
    2. Geocode API
    3. Reverse Geocode API
  3. Maps Tiles API
    1. Array of data's TileJSONs
    2. PBF file for data
    3. Styles
    4. Detail of a style
    5. Glyph range

Initialize Client

import os
from py_olamaps.OlaMaps import OlaMaps

client = OlaMaps(
    api_key=os.environ.get("OLA_MAPS_API_KEY"),
)

# OR

client = OlaMaps(client_id=os.environ.get("OLA_MAPS_CLIENT_ID"),
                 client_secret=os.environ.get("OLA_MAPS_CLIENT_SECRET"))

Routing

Directions API

import os
from py_olamaps.OlaMaps import OlaMaps

client = OlaMaps(
    api_key=os.environ.get("OLA_MAPS_API_KEY"),
)

routing_direction = client.routing.directions(
    origin="12.993103152916301,77.54332622119354",
    destination="12.972006793201695,77.5800850011884"
)

Places

Autocomplete API

import os
from py_olamaps.OlaMaps import OlaMaps

client = OlaMaps(
    api_key=os.environ.get("OLA_MAPS_API_KEY"),
)

autocomplete = client.places.autocomplete(
    input='kempe'
)

Geocode API

import os
from py_olamaps.OlaMaps import OlaMaps

client = OlaMaps(
    api_key=os.environ.get("OLA_MAPS_API_KEY"),
)

geocode = client.places.geocode(
    address='Mumbai'
)

Reverse Geocode API

import os
from py_olamaps.OlaMaps import OlaMaps

client = OlaMaps(
    api_key=os.environ.get("OLA_MAPS_API_KEY"),
)

reverse_geocode = client.places.reverse_geocode(
    latlng='12.931316595874005,77.61649243443775'
)

Map Tiles

Array of data's TileJSONs

import os
from py_olamaps.OlaMaps import OlaMaps

client = OlaMaps(
    api_key=os.environ.get("OLA_MAPS_API_KEY"),
)

array_of_data = client.map_tiles.get_tilejson_array("planet")

PBF file for data

import os
from py_olamaps.OlaMaps import OlaMaps

client = OlaMaps(
    api_key=os.environ.get("OLA_MAPS_API_KEY"),
)

pbf_file = client.map_tiles.get_pbf_file("planet", 14, 110, 1010)

Styles

import os
from py_olamaps.OlaMaps import OlaMaps

client = OlaMaps(
    api_key=os.environ.get("OLA_MAPS_API_KEY"),
)

styles = client.map_tiles.get_map_style()

Detail of a style

import os
from py_olamaps.OlaMaps import OlaMaps

client = OlaMaps(
    api_key=os.environ.get("OLA_MAPS_API_KEY"),
)

detail_of_style = client.map_tiles.get_style_details("default-light-standard")

Glyph range

import os
from py_olamaps.OlaMaps import OlaMaps

client = OlaMaps(
    api_key=os.environ.get("OLA_MAPS_API_KEY"),
)

glyph_range = client.map_tiles.get_glyph_range("Noto Sans Bold", 0, 255)

While you can provide an api_key keyword argument, we recommend using python-dotenv to add OLA_MAPS_API_KEY="My API Key" or OLA_MAPS_CLIENT_ID="My Client Id" and OLA_MAPS_CLIENT_SECRET="My Client Secret" to your .env file so that your API Key is not stored in source control.

Handling errors

Error codes are as followed:

Status Code Error Type
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
409 Conflict
422 Unprocessable Entity
429 Too Many Requests
>=500 InternalServerError

Limitation

  1. Currently, only api key is being used for sending request to Ola Maps API. Soon, the support for sending API request with client id and client secret will be added.
  2. This is because I am facing a issue with Reverse Geocode API which is a part of Places API. The issue is raised with Ola Maps team for the same.

Retries

Coming Soon...

Timeouts

Coming Soon...

Versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes that only affect static types, without breaking runtime behavior.
  2. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals).
  3. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Requirements

Python 3.9 or higher.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_olamaps-0.3.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

py_olamaps-0.3.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file py_olamaps-0.3.0.tar.gz.

File metadata

  • Download URL: py_olamaps-0.3.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.19 Linux/6.5.0-1024-azure

File hashes

Hashes for py_olamaps-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e4aafa8c5909fa78838822cd2886e80478ec85a55c85aad04790f5f0f3b01434
MD5 4af08912027656ade7ba0e21cb67620b
BLAKE2b-256 c273599ec6e7ccae9ed047090d2170c7553423e920f0ecf651a70d8cd834d65e

See more details on using hashes here.

File details

Details for the file py_olamaps-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: py_olamaps-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.19 Linux/6.5.0-1024-azure

File hashes

Hashes for py_olamaps-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 59ba818327048a99162e67c67e39550df8c79fb2a7d96a868bb496690dbaee94
MD5 02f30c8b6b6243732deb4f451061f2f0
BLAKE2b-256 b4d9784655949b28734666cd4dea3d498f48d8040bb72cfac71e1d6c0b6234ee

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page