Skip to main content

Tika REST Client

PyPi version

Python client for Apache Tika REST endpoints.

Overview

tika_rest_client provides a small, typed interface for common Apache Tika operations:

  • server health/version checks,
  • language identification,
  • text extraction (plain text or paginated),
  • metadata extraction.

It wraps HTTP/network failures with library-specific exceptions and returns structured response models.

Installation

pip install tika-rest-client

Requirements

  • Python 3.12+
  • A running Apache Tika server (for example on http://localhost:8080)

Quick Start

import io
from tika_rest_client import TikaRestClient

# IMPORTANT:
# In the current implementation, `host` is used as the full base URL.
# Example: "http://localhost:8080"
client = TikaRestClient(host="http://localhost:8080")

# Health check
print(client.check_connection())  # True / False

# Version
version = client.check_version()
print(version.response)  # e.g. "3.4.4"

# Language detection
lang = client.identify_language("Hello world")
print(lang.response)  # "en"

# Metadata extraction
metadata = client.extract_file_metadata(io.BytesIO(b"example content"))
print(metadata.metadata.general.content_type)

Main API

check_connection()

Returns True if the Tika server responds with HTTP 200 on the version endpoint, otherwise False.

check_version()

Returns a PlainTextResponse containing the server version. Raises TikaRestClientNetworkException on HTTP errors.

identify_language(input_to_test)

Accepts one of:

  • str
  • bytes
  • buffered file-like object (io.BytesIO, BinaryIO)

Returns PlainTextResponse. Raises:

  • InputFormatNotAvailableForThisEndpoint for unsupported input types,
  • LanguageIdentificationError when a language detection request fails.

extract_file_content(file_content, paginate, boilerplate, ocr)

Extracts textual content from binary file data.

  • If paginate=False: returns PlainTextResponse.
  • If paginate=True: returns DocumentDividedInMatrixResponse.

Parameters:

  • file_content: file bytes wrapped in io.BytesIO
  • paginate: enable page-oriented output model
  • boilerplate: use boilerplate endpoint variant
  • ocr: enable OCR header for Tika

extract_file_metadata(content)

Extracts metadata and returns TikaMetadataResponse.

Response Models

Depending on the method, the client returns:

  • PlainTextResponse
  • DocumentDividedInMatrixResponse
  • TikaMetadataResponse

Each response includes client_info plus method-specific payload.

Error Handling

Library-specific exceptions include:

  • InputFormatNotAvailableForThisEndpoint
  • LanguageIdentificationError
  • TikaRestClientNetworkException

Example:

from tika_rest_client.exception import TikaRestClientNetworkException

try:
    print(client.check_version().response)
except TikaRestClientNetworkException:
    print("Unable to reach Tika server.")

Contributing

Contributions are welcome.

When opening a pull request:

  1. Keep style consistent with the project.
  2. Add or update tests when behavior changes.
  3. Document public API changes.

License

This project is licensed under the Creative Commons CC-BY-SA

licensebuttons by-nc-sa

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tika_rest_client-1.0.2.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tika_rest_client-1.0.2-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file tika_rest_client-1.0.2.tar.gz.

File metadata

  • Download URL: tika_rest_client-1.0.2.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for tika_rest_client-1.0.2.tar.gz
Algorithm Hash digest
SHA256 2f37a6f825a947bb248496ce922c1833f24b74bc89839c3256c6ef46bbaa14c8
MD5 836385b08a577fe3c0b203c3dadfdce8
BLAKE2b-256 3176c939f85215e86581dd562c5ebfc67458b03213357892aafb03f099e7e930

See more details on using hashes here.

Provenance

The following attestation bundles were made for tika_rest_client-1.0.2.tar.gz:

Publisher: publish-to-test-pypi.yml on CyberCRI/tika-rest-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tika_rest_client-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for tika_rest_client-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2c157134ecdff9b93f0950718fc989f35528eb3020c93f3af226d60c27dbf0fc
MD5 23fd88c55d4a3d8b541a25733776fd07
BLAKE2b-256 be02a39d31627990fbe7d2b2ee3cab03bbb42d9def60dda8d16addd3e56048d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for tika_rest_client-1.0.2-py3-none-any.whl:

Publisher: publish-to-test-pypi.yml on CyberCRI/tika-rest-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 files

1.0.1

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page