Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

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.

Files for pyphoton, version 0.9.3
Filename, size File type Python version Upload date Hashes
Filename, size pyphoton-0.9.3-py3-none-any.whl (6.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pyphoton-0.9.3.tar.gz (4.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page