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

If you need some code ready to use, spike.py is a good starting point

Execute queries

Python Photon client allows you to make queries to Photon service 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 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

  • osm_tags: a string or list containing osm tags filters

  • bbox: a string with comma-separated values or list containing bounding box coordinates

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 …

Deal with errors

If there’s an error in 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)

Run tests

pip install -r requirements-dev.txt
make test

WIP Features

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-1.0.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

pyphoton-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyphoton-1.0.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for pyphoton-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bcbed4bdadbe3f936d8500ce512cee840c7305e54dd8703303dd29a411fb1ad2
MD5 7166ef717c04ca865dd0e4979c320604
BLAKE2b-256 4f0fbb916dba837e4f0409cce79dcd44728c3051f12249290d7cc0c2c042268a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyphoton-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for pyphoton-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf09ca1a68ec62b542d59b9a042a886e811ada620015e2da207efd30c6b0914c
MD5 4f0da56ae48a3fbb6167087112dfa523
BLAKE2b-256 4e8335146045ce967e6a43bdd0480a97c58bc2cfe000bc9f539ab4b9734b3a20

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