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

Uploaded Source

Built Distribution

pyphoton-0.9.3-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyphoton-0.9.3.tar.gz
  • Upload date:
  • Size: 4.2 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.3.tar.gz
Algorithm Hash digest
SHA256 4e8950338a9d2edcd8c3de3741da772c5df312c6e522bf6b8d4fbd9bbb71c5d3
MD5 858d7a03f36b0f0b20af80736145d2f4
BLAKE2b-256 d735e13f6688139966abbc667c5ee595e8a1e31f11f9b8315b65424e5635450d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyphoton-0.9.3-py3-none-any.whl
  • Upload date:
  • Size: 6.5 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ddb493cf849a873145290dd71f3fb7cd34f7ef97e7e39c8ffee95ac72f84aa1a
MD5 9843345ac6e61376881d70bde0b536d8
BLAKE2b-256 672701a8e2914e8835eb43ae8cca628a391d3aef59bc099d138d5479f76ba3ce

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