Skip to main content

pageindex-search

Python client for Page Search API by PageIndex. Upload a PDF, ask up to 10 questions at once, and get back the pages that answer each one, ranked by relevance. Every page is read.

pip install pageindex-search

Create an API key in the console and set it:

export PAGEINDEX_SEARCH_API_KEY=pis_live_...

Quick start

from pageindex_search import PageSearch

client = PageSearch()

doc = client.documents.upload("3M_2018_10K.pdf")
result = client.search(doc, ["What was capital expenditure in 2018?", "Who is the CEO?"])

for answer in result.results:
    print(answer.question)
    for page in answer.pages:
        print(f"  page {page.page}: {page.relevance}")

print(f"cost ${result.usage.cost_usd}, credit left ${result.usage.balance_usd}")

Upload a document once and search it as often as you like; uploading the same file again returns the same document. Documents are kept until you delete them:

for doc in client.documents.list():  # every document, newest first, a page at a time
    print(doc.id, doc.filename, doc.pages)

client.search("doc_60a07bcef3094b68806070f2", ["What was revenue in 2018?"])  # search one again by its id
client.documents.delete("doc_60a07bcef3094b68806070f2")

Reference

PageSearch(api_key=None, base_url=None, timeout=120, max_retries=2) The key defaults to PAGEINDEX_SEARCH_API_KEY.
documents.upload(file, wait=True) A path, bytes or an open file. Returns a Document, ready to search unless wait=False.
search(document, questions, top_k=None, idempotency_key=None) Up to 10 questions. Each answer lists the pages likely to help (relevance 0.3 or more; 0.2 or more when fewer than 3 are; possibly none), or exactly top_k. A search retried after a timeout is not charged twice.
documents.list(limit=20, after=None) Your documents, newest first. Loop over it for every document; .data and .has_more are one page.
documents.get(id), documents.delete(document) One document; delete one.
usage(start=None, end=None) Uploads, searches and cost by day, your credit and stored pages.

Before 0.2 these were upload(), document(), documents(), iter_documents() and delete() on the client; they still work, with a warning, for now.

Errors raise PageSearchError, with the API's status, code, message and request_id.

See the API reference for every field and the pricing.

Metadata

Release files for pageindex-search 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pageindex-search 0.2.0
File Size Uploaded Provenance Actions
pageindex_search-0.2.0.tar.gz 8.4 kB Without provenance Details for pageindex_search-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pageindex-search 0.2.0
File Interpreter ABI Platform Actions
pageindex_search-0.2.0-py3-none-any.whl Python 3 none any Details for pageindex_search-0.2.0-py3-none-any.whl

Total release size: 16.8 kB

Release files / pageindex_search-0.2.0.tar.gz

Download URL pageindex_search-0.2.0.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1753bc39e88c35d14ab88097f0ae7efce1985509e9f26fe48c364a35864926ce
BLAKE2b-256 checksum
How to use checksums
b72df8d965afecfc21c2bdfa2f5ceea11d8830ab91485a1ebaf679d9b7f5cabf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pageindex_search-0.2.0-py3-none-any.whl

Download URL pageindex_search-0.2.0-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c371a42534da291b8d390c8fb7794b0797a6c9b129d369ed83b74987d51a9cd
BLAKE2b-256 checksum
How to use checksums
c104a638ce6fac3d82d6dcc7fda14c271bf3bfd8a03e080144ab7f477142d795
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for pageindex-search 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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