Skip to main content

enables Pythonic access to data exports from TYPO3-find

Project description

txpyfind enables access to data exports from TYPO3-find in Python. Details on the TYPO3-find setup required for data exports can be found in the section Data export in the README file of that repository.

The three JSON formats json-all, json-solr-results and raw-solr-response are already available in the TYPO3 extension, see the partials used to create the three formats.

You can use the client class available in this Python package to query these exports. A simple parser for the returned JSON objects is also available.

See slubfind for a real-world implementation example, including custom query types and instance-specific response parsing.

Installation

… via PyPI

pip install txpyfind

… or from GitHub source

pip install git+https://github.com/slub/txpyfind.git

Command-Line Usage

After installation, the txpyfind command is available (also via python -m txpyfind).

Query

Execute a search query:

txpyfind --url https://katalog.slub-dresden.de query "manfred bonitz"

With a facet filter and pagination:

txpyfind --url https://katalog.slub-dresden.de query "python" --facet format_de14="Book, E-Book" --page 1 --count 10

Multiple --facet options can be combined:

txpyfind --url https://katalog.slub-dresden.de query "python" --facet format_de14="Book, E-Book" --facet language=German

Query Type

Use --type to select a query type (e.g. author, title). Valid values depend on the TYPO3-find instance. Use --query-type (repeatable) to whitelist the types accepted by --type; if omitted, only default is allowed:

txpyfind --url https://katalog.slub-dresden.de --query-type default --query-type author --query-type title query "bonitz" --type author

Document

Fetch a single document by ID:

txpyfind --url https://katalog.slub-dresden.de --document-path id --export-format json-ld document 0-1132486122

Scroll

Fetch all results for a query:

txpyfind --url https://katalog.slub-dresden.de scroll "manfred bonitz" --batch 10

Stream results as JSONL (one JSON object per line), useful for piping:

txpyfind --url https://katalog.slub-dresden.de scroll "manfred bonitz" --stream | jq .id

Show Request URL

Use --show-url to print the request URL instead of fetching the response. This works with all subcommands:

txpyfind --url https://katalog.slub-dresden.de --show-url query "python" --facet format_de14="Book, E-Book"
txpyfind --url https://katalog.slub-dresden.de --document-path id --export-format json-ld --show-url document 0-1132486122
txpyfind --url https://katalog.slub-dresden.de --show-url scroll "python" --batch 10

Export Format

Use --export-format to select the response format. The three formats built into TYPO3-find are raw-solr-response (default), json-all, and json-solr-results. Individual instances may provide additional formats:

txpyfind --url https://katalog.slub-dresden.de --export-format json-solr-results query "manfred bonitz"
txpyfind --url https://katalog.slub-dresden.de --document-path id --export-format json-ld document 0-1132486122

Environment Variable

Set TXPYFIND_URL to avoid repeating the --url option:

export TXPYFIND_URL=https://katalog.slub-dresden.de
txpyfind query "manfred bonitz"
txpyfind --document-path id --export-format json-ld document 0-1132486122

Python Usage Example

from txpyfind.client import Find
# create Find instance
slub_find = Find("https://katalog.slub-dresden.de", document_path="id", export_format="json-ld")
# retrieve JSON-LD data (detail view)
slub_ld_doc = slub_find.get_document("0-1132486122")
# retrieve JSON-LD data (query view)
slub_ld_q_default = slub_find.get_query("manfred bonitz")
# query with a single facet (dict)
slub_find.get_query("python", facet={"format_de14": "Book, E-Book"})
# query with multiple facets (list of dicts)
slub_find.get_query("python", facet=[{"format_de14": "Book, E-Book"}, {"language": "German"}])

License

This project is licensed under the GNU General Public License v3 (GPLv3). See the LICENSE file for the full license text.

Project details


Download files

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

Source Distribution

txpyfind-1.3.0.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

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

txpyfind-1.3.0-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file txpyfind-1.3.0.tar.gz.

File metadata

  • Download URL: txpyfind-1.3.0.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for txpyfind-1.3.0.tar.gz
Algorithm Hash digest
SHA256 06ecaaabb605703fd795075ac091b8f511dd7a9d4c421180d011d3739e6667ca
MD5 d0bdaf653c6857ae87aeff9bec4f9203
BLAKE2b-256 0aa2a825437442645546225a91fd2f700e5ab75784213f32d7fdb13d56a761ed

See more details on using hashes here.

File details

Details for the file txpyfind-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: txpyfind-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for txpyfind-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 55157df3c2708643149b6110dab0ff5a150c5830031d33e06ef45d1c641700f1
MD5 c323dbea1f30e3bce16eb34e1a1563eb
BLAKE2b-256 6c003ab0093a53843b7eb4ff423ce25f638ea7d335c1ab22e2b5a258ea01fb82

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page