Metadata-Version: 2.4
Name: osm-shortlink
Version: 1.3.0
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Zero-Clause BSD (0BSD)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Rust
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
License-File: LICENSE
Summary: OpenStreetMap shortlink encoder and decoder
Keywords: decoder,encoder,openstreetmap,osm,shortlink,url
Author-email: Kamil Monicz <kamil@monicz.dev>
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Issues, https://github.com/Zaczero/osm-shortlink/issues
Project-URL: Repository, https://github.com/Zaczero/osm-shortlink

# osm-shortlink

![Python Free-Threaded Compatible](https://shields.monicz.dev/badge/Free--Threaded-Compatible-blue?logo=Python&logoColor=f0c74c)
[![PyPI - Python Version](https://shields.monicz.dev/pypi/pyversions/osm-shortlink)](https://pypi.org/project/osm-shortlink)
[![Liberapay Patrons](https://shields.monicz.dev/liberapay/patrons/Zaczero?logo=liberapay&label=Patrons)](https://liberapay.com/Zaczero/)
[![GitHub Sponsors](https://shields.monicz.dev/github/sponsors/Zaczero?logo=github&label=Sponsors&color=%23db61a2)](https://github.com/sponsors/Zaczero)

Fast and correct OpenStreetMap shortlink encoder and decoder implementation in Rust with Python bindings. Shortlinks allow you to represent a location on the map with a short code.

## Installation

Pre-built binary wheels are available for Linux, macOS, and Windows, with support for both x64 and ARM architectures.

```sh
pip install osm-shortlink
```

## Basic usage

```py
from osm_shortlink import shortlink_encode
shortlink_encode(0.054, 51.510, 9)  # -> '0EEQhq--'
shortlink_encode(19.579, 51.876, 19)  # -> '0OP4tR~rx'
shortlink_encode(0, 0, 23)  # ValueError: Invalid zoom: must be between 0 and 22, got 23

from osm_shortlink import shortlink_decode
shortlink_decode('0EEQhq--')  # -> (0.054, 51.510, 9)
shortlink_decode('0OP4tR~rx')  # -> (19.579, 51.876, 19)
shortlink_decode('X')  # ValueError: Invalid shortlink: too short
```

## Format specification

<https://wiki.openstreetmap.org/wiki/Shortlink>

