pyphoton
🗺 Light Photon client written in Python
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 …
Reverse search
Python Photon client allows you to make reverse search.
from pyphoton import Photon
client = Photon()
locations = client.reverse(latitude=52, longitude=10)
for location in locations:
print ('🌉 Location #{0}\n{1}\n'.format(location.osm_id, location))
You can pass to the reverse method the following parameters:
latitude and longitude: use them to search using a geo position
limit: limit number of results
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
Method to fetch latest data
Metadata
Release files for pyphoton 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyphoton-1.0.0.tar.gz | 4.6 kB | Without provenance | Details for pyphoton-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyphoton-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for pyphoton-1.0.0-py3-none-any.whl |
Total release size: 9.8 kB
Release files / pyphoton-1.0.0.tar.gz
| Download URL | pyphoton-1.0.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bcbed4bdadbe3f936d8500ce512cee840c7305e54dd8703303dd29a411fb1ad2
|
|
BLAKE2b-256 checksum How to use checksums |
4f0fbb916dba837e4f0409cce79dcd44728c3051f12249290d7cc0c2c042268a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pyphoton-1.0.0-py3-none-any.whl
| Download URL | pyphoton-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf09ca1a68ec62b542d59b9a042a886e811ada620015e2da207efd30c6b0914c
|
|
BLAKE2b-256 checksum How to use checksums |
4e8335146045ce967e6a43bdd0480a97c58bc2cfe000bc9f539ab4b9734b3a20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for pyphoton 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.