Skip to main content

Simple wrapper module for the OpenCage Geocoder API

Project description

Build Status Kritika Analysis Status PyPI version

OpenCage Data Geocoding Module for Python

A Python module that uses OpenCage Data's geocoder.

Usage

Install the module:

pip install opencage

Load the module:

from opencage.geocoder import OpenCageGeocode

Create an instance of the geocoder module, passing a valid OpenCage Data Geocoder API key as a parameter to the geocoder modules's constructor:

key = 'your-api-key-here'
geocoder = OpenCageGeocode(key)

Pass a string containing the query or address to be geocoded to the modules's geocode method:

query = "82 Clerkenwell Road, London";
result = geocoder.geocode(query)

You can add additional parameters:

result = geocoder.geocode('London', no_annotations=1, language='es')

Reverse geocoding

Turn a lat/long into an address with the reverse_geocode method:

results = geocoder.reverse_geocode(51.51024, -0.10303)

Exceptions

If anything goes wrong, then an exception will be raised:

  • InvalidInputError for non-unicode query strings
  • UnknownError if there's some problem with the API (bad results, 500 status code, etc)
  • RateLimitExceededError if you go past your rate limit

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

opencage-1.1.6.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

opencage-1.1.6-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file opencage-1.1.6.tar.gz.

File metadata

  • Download URL: opencage-1.1.6.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for opencage-1.1.6.tar.gz
Algorithm Hash digest
SHA256 fdb5a9f346ed354e4075d234a359c558c04fdce6df3de803babbce3ae1bb19e3
MD5 67966ff047bd691fe9a9a8f1e18b497c
BLAKE2b-256 34891b5818efcd5882bd4a299466937720541539a61b655f3530f1951b56ec34

See more details on using hashes here.

File details

Details for the file opencage-1.1.6-py3-none-any.whl.

File metadata

  • Download URL: opencage-1.1.6-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for opencage-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 c2c2a84228fedd1dddfca8c819e412f28bb45adb5e5dc6c3d743abf512e26637
MD5 d18b3f8b3757d37d434d973d71dc755a
BLAKE2b-256 b31db62f20327fc0cc6e61d64748cbf92fefd1beab875090decb54ae190c6048

See more details on using hashes here.

Supported by

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