Skip to main content

Photon Python client

Project description

🗺 Light Photon client written in Python

Latest Version codecov Build Status License: MIT

Install

pip install pyphoton

Usage

Python Photon client allows you to make queries to Photon easily.

from pyphoton import Photon


client = Photon()
location = client.query('berlin', limit=1)

print (location.city)
print (location.latitude)
print (location.longitude)

Photon object accepts two parameters:

  • host: the url where Photon instance is running (default https://photon.komoot.de)

  • language: the preferred language (default is en)

You can pass to the query method the following parameters along the query string:

  • limit: limit number of results

  • language: force language in the query

  • latitude and longitude: use them to search with priority to a geo position

  • location_bias_scale: use to search with location bias

Location object (or objects if you don’t set limit=1) is generated from the json returned and contains all the information you need: name, state, street, city, osm attributes, extent_from.latitude, extent_from.longitude, extent_to.latitude, extent_to.longitude …

If there’s an with your query, a PhotonException will be raised

from pyphoton import Photon
from pyphoton.errors import PhotonException


client = Photon()
try:
    location = client.query('', limit=1)
except PhotonException as ex:
    print (ex)

WIP Features

  • Reverse search

  • BBox search

  • Method to fetch latest data

Run tests

pip install -r requirements-dev.txt
make test

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

pyphoton-0.9.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

pyphoton-0.9.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file pyphoton-0.9.0.tar.gz.

File metadata

  • Download URL: pyphoton-0.9.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/18.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for pyphoton-0.9.0.tar.gz
Algorithm Hash digest
SHA256 2b528519c25ce147eda1d2cd731ff3838fcb9ca8ac23a79093b164c56b980d83
MD5 870e2594a504f4319ab8ad98504b4930
BLAKE2b-256 dc2f4e7ec67516e7f16e960f7d4a254d764b2cbc277286623162ebabcb7dc763

See more details on using hashes here.

File details

Details for the file pyphoton-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: pyphoton-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/18.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for pyphoton-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 21a4d74e47670373a6bd2ea81c66c2a4c6628ad61a34be8f31f2d40ddf71f1fc
MD5 3d4567d8a5a790a5d4718985056dc057
BLAKE2b-256 647cf25d81501bbd64679b08783db30b19414279bc74842f794d064a42884b30

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