{"id":15355280,"url":"https://github.com/astagi/pyphoton","last_synced_at":"2025-04-15T06:28:31.309Z","repository":{"id":46659949,"uuid":"243100273","full_name":"astagi/pyphoton","owner":"astagi","description":"🗺 Light Komoot Photon client written in Python","archived":false,"fork":false,"pushed_at":"2024-05-21T00:45:29.000Z","size":53,"stargazers_count":6,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T17:05:03.835Z","etag":null,"topics":["geocoding","hacktoberfest","localization","location","maps","python"],"latest_commit_sha":null,"homepage":"https://photon.komoot.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/astagi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-25T20:53:31.000Z","updated_at":"2022-08-26T01:04:46.000Z","dependencies_parsed_at":"2024-06-11T17:20:52.110Z","dependency_job_id":null,"html_url":"https://github.com/astagi/pyphoton","commit_stats":{"total_commits":32,"total_committers":3,"mean_commits":"10.666666666666666","dds":0.09375,"last_synced_commit":"7bc71c5bd86c0d70580c71ea6945b44d11bd6b1d"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astagi%2Fpyphoton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astagi%2Fpyphoton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astagi%2Fpyphoton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astagi%2Fpyphoton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/astagi","download_url":"https://codeload.github.com/astagi/pyphoton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249019977,"owners_count":21199465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geocoding","hacktoberfest","localization","location","maps","python"],"created_at":"2024-10-01T12:23:39.911Z","updated_at":"2025-04-15T06:28:31.294Z","avatar_url":"https://github.com/astagi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyphoton\n\n🗺 Light Photon client written in Python\n\n[![Latest Version](https://img.shields.io/pypi/v/pyphoton.svg)](https://pypi.python.org/pypi/pyphoton/)\n[![codecov](https://codecov.io/gh/astagi/pyphoton/branch/master/graph/badge.svg)](https://codecov.io/gh/astagi/pyphoton)\n[![Build Status](https://github.com/astagi/pyphoton/actions/workflows/ci.yml/badge.svg)](https://github.com/astagi/pyphoton/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/astagi/pyphoton/blob/master/LICENSE)\n\n## Install\n\n```sh\npip install pyphoton\n```\n\n## Usage\n\nIf you need some code ready to use, [spike.py](https://github.com/astagi/pyphoton/blob/master/spike.py) is a good starting point\n\n### Execute queries\n\nPython Photon client allows you to make queries to Photon service easily.\n\n```py\nfrom pyphoton import Photon\n\n\nclient = Photon()\nlocation = client.query('berlin', limit=1)\n\nprint (location.city)\nprint (location.latitude)\nprint (location.longitude)\n```\n\n`Photon` object accepts two parameters:\n\n- `host`: the url where Photon instance is running (default `https://photon.komoot.io`)\n- `language`: the preferred language (default is `en`)\n\nYou can pass the `query` method the following parameters along the query string:\n\n- `limit`: limit number of results\n- `language`: force language in the query\n- `latitude` and `longitude`: use them to search with priority to a geo position\n- `location_bias_scale`: use to search with location bias\n- `osm_tags`: a `string` or `list` containing [osm tags filters](https://github.com/komoot/photon#filter-results-by-tags-and-values)\n- `bbox`: a `string` with comma-separated values or `list` containing [bounding box coordinates](https://github.com/komoot/photon#filter-results-by-bounding-box)\n\n`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 ...\n\n### Reverse search\n\nPython Photon client allows you to make reverse search.\n\n```py\nfrom pyphoton import Photon\n\n\nclient = Photon()\nlocations = client.reverse(latitude=52, longitude=10)\n\nfor location in locations:\n    print ('🌉 Location #{0}\\n{1}\\n'.format(location.osm_id, location))\n```\n\nYou can pass to the `reverse` method the following parameters:\n\n- `latitude` and `longitude`: use them to search using a geo position\n- `limit`: limit number of results\n\n### Deal with errors\n\nIf there's an error in your query, a `PhotonException` will be raised\n\n```py\nfrom pyphoton import Photon\nfrom pyphoton.errors import PhotonException\n\n\nclient = Photon()\ntry:\n    location = client.query('', limit=1)\nexcept PhotonException as ex:\n    print (ex)\n```\n\n## Run tests\n\n```sh\npip install -r requirements-dev.txt\nmake test\n```\n\n## WIP Features\n\n- Method to fetch [latest data](http://download1.graphhopper.com/public/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastagi%2Fpyphoton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastagi%2Fpyphoton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastagi%2Fpyphoton/lists"}