# Transkribus API Client
`transkribus-client` provides a Python 3.6+ API client to interact with Transkribus.
## Authentication
Most of the API requires an authentication with a Transkribus account.
To authenticate, you can give your email and password to the client:
```python
from getpass import getpass
from transkribus import TranskribusAPI
api = TranskribusAPI()
TranskribusAPI.login('user@example.com', getpass())
```
Alternatively, you can use the `options_from_env` helper and some environment variables:
```python
from transkribus import TranskribusAPI, options_from_env
api = TranskribusAPI(**options_from_env())
```
You can define the following environment variables:
`TRANSKRIBUS_API_URL`
: Base URL of the Transkribus API. Defaults to `https://transkribus.eu/TrpServer/rest`.
`TRANSKRIBUS_EMAIL`
: Email address of the user to authenticate with.
`TRANSKRIBUS_PASSWORD`
: Password of the user to authenticate with.
## Usage
### Browsing from collections to transcripts
```python
from transkribus.api import TranskribusAPI, options_from_env
from transkribus.models import Collection
api = TranskribusAPI(**options_from_env())
for collection_data in api.list_collections():
for document in Collection(collection_data).get_documents(api):
for page in document.get_pages(api):
print(str(page.get_transcript()))
```
### Exporting a collection
```python
collection = Collection(COLLECTION_ID)
export_job = collection.export(api)
export_job.wait_for_result(api)
export_job.download_result('path/to/export.zip')
```
### Parsing a PageXML file
```python
from transkribus.pagexml import PageXmlPage
for region in PageXmlPage('/path/to/transcript.xml').page.text_regions:
for line in region.lines:
print(line.text)
```
## Contributing
Issues and patches are welcome! Here are some tips to help you get started coding.
### Unit tests
We use [tox](https://tox.wiki) for unit tests. You can install and run it like so:
```
pip install tox
tox
```
### Linting
We use [pre-commit](https://pre-commit.com/) with [black](https://github.com/psf/black) to automatically format the Python source code of this project.
To be efficient, you should run pre-commit before committing (hence the nameā¦).
To do that, run once:
```
pip install pre-commit
pre-commit install
```
The linting workflow will now run on modified files before committing, and will fix issues for you.
If you want to run the full workflow on all the files: `pre-commit run -a`.
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/teklia/arkindex/transkribus",
"name": "transkribus-client",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "api client transkribus",
"author": "Teklia <contact@teklia.com>",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/ee/5c/4c886937894bdaf0e365f7768788667ad3aab52dc69b139544944c5075b9/transkribus-client-0.3.3.tar.gz",
"platform": null,
"description": "# Transkribus API Client\n\n`transkribus-client` provides a Python 3.6+ API client to interact with Transkribus.\n\n## Authentication\n\nMost of the API requires an authentication with a Transkribus account.\nTo authenticate, you can give your email and password to the client:\n\n```python\nfrom getpass import getpass\nfrom transkribus import TranskribusAPI\napi = TranskribusAPI()\nTranskribusAPI.login('user@example.com', getpass())\n```\n\nAlternatively, you can use the `options_from_env` helper and some environment variables:\n\n```python\nfrom transkribus import TranskribusAPI, options_from_env\napi = TranskribusAPI(**options_from_env())\n```\n\nYou can define the following environment variables:\n\n`TRANSKRIBUS_API_URL`\n: Base URL of the Transkribus API. Defaults to `https://transkribus.eu/TrpServer/rest`.\n\n`TRANSKRIBUS_EMAIL`\n: Email address of the user to authenticate with.\n\n`TRANSKRIBUS_PASSWORD`\n: Password of the user to authenticate with.\n\n## Usage\n\n### Browsing from collections to transcripts\n\n```python\nfrom transkribus.api import TranskribusAPI, options_from_env\nfrom transkribus.models import Collection\napi = TranskribusAPI(**options_from_env())\nfor collection_data in api.list_collections():\n for document in Collection(collection_data).get_documents(api):\n for page in document.get_pages(api):\n print(str(page.get_transcript()))\n```\n\n### Exporting a collection\n\n```python\ncollection = Collection(COLLECTION_ID)\nexport_job = collection.export(api)\nexport_job.wait_for_result(api)\nexport_job.download_result('path/to/export.zip')\n```\n\n### Parsing a PageXML file\n\n```python\nfrom transkribus.pagexml import PageXmlPage\nfor region in PageXmlPage('/path/to/transcript.xml').page.text_regions:\n for line in region.lines:\n print(line.text)\n```\n\n## Contributing\n\nIssues and patches are welcome! Here are some tips to help you get started coding.\n\n### Unit tests\n\nWe use [tox](https://tox.wiki) for unit tests. You can install and run it like so:\n\n```\npip install tox\ntox\n```\n\n### Linting\n\nWe use [pre-commit](https://pre-commit.com/) with [black](https://github.com/psf/black) to automatically format the Python source code of this project.\n\nTo be efficient, you should run pre-commit before committing (hence the name\u2026).\n\nTo do that, run once:\n\n```\npip install pre-commit\npre-commit install\n```\n\nThe linting workflow will now run on modified files before committing, and will fix issues for you.\n\nIf you want to run the full workflow on all the files: `pre-commit run -a`.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Unofficial API client for the Transkribus project",
"version": "0.3.3",
"project_urls": {
"Homepage": "https://gitlab.com/teklia/arkindex/transkribus"
},
"split_keywords": [
"api",
"client",
"transkribus"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "29410a75be5bce6669af1cd320364ccacb7c0a8dfff081d6dbbbf72f43050739",
"md5": "58fe401f3d206924ea4f589f93a09203",
"sha256": "d3bc9eff2b7b53b2a5dda91a9a5fd11b20d62b7dabdab643133783fc4257dec3"
},
"downloads": -1,
"filename": "transkribus_client-0.3.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "58fe401f3d206924ea4f589f93a09203",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 11369,
"upload_time": "2022-09-05T18:51:54",
"upload_time_iso_8601": "2022-09-05T18:51:54.307150Z",
"url": "https://files.pythonhosted.org/packages/29/41/0a75be5bce6669af1cd320364ccacb7c0a8dfff081d6dbbbf72f43050739/transkribus_client-0.3.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ee5c4c886937894bdaf0e365f7768788667ad3aab52dc69b139544944c5075b9",
"md5": "13353ac9bbe6ba885678d5035675982f",
"sha256": "d469c990078c360f1292dc12e748c2742eae55389e702eeacaed9e36ad661619"
},
"downloads": -1,
"filename": "transkribus-client-0.3.3.tar.gz",
"has_sig": false,
"md5_digest": "13353ac9bbe6ba885678d5035675982f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 10631,
"upload_time": "2022-09-05T18:51:56",
"upload_time_iso_8601": "2022-09-05T18:51:56.066449Z",
"url": "https://files.pythonhosted.org/packages/ee/5c/4c886937894bdaf0e365f7768788667ad3aab52dc69b139544944c5075b9/transkribus-client-0.3.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-09-05 18:51:56",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "teklia",
"gitlab_project": "arkindex",
"lcname": "transkribus-client"
}