Metadata-Version: 2.4
Name: transkribus-api
Version: 0.1.1
Summary: Transkribus API Client.
Author-email: "J. Nathanael Philipp" <jnathanael@philipp.land>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/jnphilipp/transkribus-api
Project-URL: Bug Tracker, http://github.com/jnphilipp/transkribus-api/issues
Keywords: transkribus,api,metagrapho,rest
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
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: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: lxml~=6.1.3
Requires-Dist: Pillow~=12.3.0
Requires-Dist: requests~=2.34.0
Dynamic: license-file

# Transkribus API Client

![Tests](https://github.com/jnphilipp/transkribus-api/actions/workflows/tests.yml/badge.svg)

Python bindings for the new [Transkribus Developer Platform](https://docs.transkribus.org), the old [Transkribus Metagrapho/Processing API](https://www.transkribus.org/metagrapho/documentation) and the [Transkribus Legacy API](https://help.transkribus.org/transkribus-legacy-api).
This project unites my previous separate projects for the [Metagrapho/Processing APIt](https://github.com/jnphilipp/transkribus_metagrapho_api) and [Legacy API](https://github.com/jnphilipp/transkribus_rest_api).


## Usage

```python
import lxml
import transkribus

from time import sleep

with transkribus.open(USERNAME, PASSWORD) as api:
    process_ids = [
        api.metagrapho.process(IMAGE_PATH, line_detection=49272, htr_id=51170)["processId"],
        api.metagrapho.process(IMAGE_URL, line_detection=49272, htr_id=51170)["processId"],
    ]

    done = set()
    while True:
        for process_id in process_ids:
            if process_id in done:
                continue
            match api.metagrapho.status(process_id)["status"].lower():
                case "finished":
                    with open(f"{process_id}-page.xml", "wb") as f:
                        lxml.etree.tostring(api.metagrapho.page(process_id), pretty_print=True)
                    with open(f"{process_id}-alto.xml", "wb") as f:
                        lxml.etree.tostring(api.metagrapho.alto(process_id), pretty_print=True)
                    done.add(process_id)
                case "failed":
                    print(f"{process_id} FAILED")
                    done.add(process_id)
        if len(done) == len(process_ids):
            break
        sleep(10)
```
