Skip to main content

stract-api-python

Get the information you need from your documents

Typical workflow

  1. Create a struct (createStruct) and add fields (createFields) describing the data to extract.
  2. Upload documents to a catalog or on their own (uploadDocument, uploadTextDocument, and their no-catalog variants).
  3. Create a job (createJob) with the struct and the catalog or document IDs. Specifying a catalog or multiple document IDs will run the job on all the relevant documents automatically.
  4. Poll getJobById until the job is complete, then download the output (getJobOutputJson or getJobOutputCsv). Output will include one line for every document included in the job.

For a single short document, uploadDocumentProcessAndRunJob or uploadTextDocumentAndRunJob does steps 2-4 in one call.

Machine authentication

Programmatic access to the API is authenticated with an API key. Include the API key in every request as a bearer token in the authorization header:

authorization: bearer [apiKey]

SDKs

Official SDKs are available for the following languages:

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 0.10.0
  • Package version: 0.10.1
  • Generator version: 7.27.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen

Requirements.

Python 3.11+

Packaging uses standard [project] metadata and [dependency-groups] (PEP 621/735). Install the package with python -m pip install .; install development dependencies with Poetry 2.2 or newer using poetry install, or pip 25.1 or newer using python -m pip install --group dev. The latter installs the group, not the package.

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/mattpmoreno/stract-api-python.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/mattpmoreno/stract-api-python.git)

Then import the package:

import stract_api

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import stract_api

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

import stract_api
from stract_api.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.stract-api.com
# See configuration.py for a list of all supported configuration parameters.
configuration = stract_api.Configuration(
    host = "https://api.stract-api.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization: bearerAuth
configuration = stract_api.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)


# Enter a context with an instance of the API client
with stract_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = stract_api.AccountApi(api_client)
    create_account_user_request = stract_api.CreateAccountUserRequest() # CreateAccountUserRequest | 

    try:
        # Add a user to the current account
        api_response = api_instance.create_account_user(create_account_user_request)
        print("The response of AccountApi->create_account_user:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling AccountApi->create_account_user: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://api.stract-api.com

Class Method HTTP request Description
AccountApi create_account_user POST /account/user Add a user to the current account
AccountApi edit_account PUT /account Edit the current account
AccountApi get_account GET /account Get the current account
AccountApi get_account_users GET /account/user List users in the current account
AccountCreditLedgerApi get_account_credit_ledger_for_spending_user GET /account_credit_ledger List credit ledger entries
ApiKeyApi get_api_keys GET /api-key List the account's API keys
CatalogApi create_catalog POST /catalog Create a catalog
CatalogApi delete_catalog DELETE /catalog/{catalogId} Delete a catalog
CatalogApi get_catalogs GET /catalog List catalogs
CreditsApi get_current_credits GET /current_credits Get the user's credit balance
CreditsApi get_current_org_credits GET /current_org_credits Get the organization credit balance
DocumentApi delete_document DELETE /document/{documentId} Delete a document
DocumentApi get_catalog_documents GET /catalog/{catalogId}/document List documents in a catalog
DocumentApi get_document_link GET /document/{documentId}/link Get a document download link
DocumentApi get_document_text GET /catalog/{catalogId}/document/{documentId}/text Get a document's extracted text
DocumentApi get_documents_for_job GET /job/{jobId}/document List documents in a job
DocumentApi get_user_documents GET /document List all documents
DocumentApi upload_document POST /catalog/{catalogId}/document Upload a file to a catalog
DocumentApi upload_document_from_url POST /catalog/{catalogId}/document/url Upload a file from a URL to a catalog
DocumentApi upload_document_from_url_no_catalog POST /document/url Upload a file from a URL
DocumentApi upload_document_no_catalog POST /document Upload a file without a catalog
DocumentApi upload_text_document POST /catalog/{catalogId}/document/text Add a text document to a catalog
DocumentApi upload_text_document_no_catalog POST /document/text Create a text document without a catalog
FieldApi create_fields POST /struct/{structId}/field Add fields to a struct
FieldApi delete_field DELETE /field/{fieldId} Delete a field
FieldApi edit_field PUT /field/{fieldId} Edit a field
FieldApi get_fields GET /struct/{structId}/field List fields of a struct
JobApi archive_job POST /job/{jobId}/archive Archive a job
JobApi cancel_job POST /job/{jobId}/cancel Cancel a job
JobApi create_job POST /struct/{structId}/job Create an extraction job
JobApi get_job_by_id GET /job/{jobId} Get a job
JobApi get_job_output_csv GET /job/{jobId}/output_csv Download job output as CSV
JobApi get_job_output_json GET /job/{jobId}/output_json Download job output as JSON
JobApi get_struct_jobs GET /struct/{structId}/job List jobs for a struct
JobApi get_user_jobs GET /job List all jobs
JobApi upload_document_process_and_run_job POST /struct/{structId}/job/sync Upload a file, run a job, and return the output
JobApi upload_text_document_and_run_job POST /struct/{structId}/job/sync/text Submit text, run a job, and return the output
JobDocumentApi get_job_document_output GET /job_document/{jobDocId}/output Get extracted data for one job document
JobDocumentApi get_job_documents GET /job/{jobId}/job_document List per-document status for a job
LlmModelApi get_llm_models GET /llm_model List LLM models
StructApi archive_struct POST /struct/{structId}/archive Archive a struct
StructApi create_struct POST /struct Create a struct
StructApi get_structs GET /struct List structs
UserApi edit_my_user PUT /my_user Edit the current user
UserApi get_my_user GET /my_user Get the current user

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

bearerAuth

  • Type: Bearer authentication

Author

matt@stract-api.com

Request headers

Header names are compared case-insensitively in all Python client libraries. Request headers are copied; supplying _headers does not change the caller's dict or the client's shared defaults. The public _headers argument retains its dict validation and existing value serialization. Pydantic can coerce mappings such as HTTPX Headers to a dict, combining repeated fields into a single value; _headers does not provide a repeated-field or list-of-pairs API.

Precedence, from lowest to highest:

  1. _headers (within one dict, the last inserted case variant wins).
  2. Explicit OpenAPI header parameters and generated Content-Type (or _content_type). Generated Accept is added only when neither _headers nor explicit header parameters contain an Accept case variant.
  3. ApiClient.default_headers (including headers set with set_default_header).
  4. The client's cookie setting, for Cookie.
  5. Authentication headers. A non-empty _request_auth replaces configured authentication for that call; {} retains configured authentication. Cookie authentication appends to the selected Cookie value.

This retains the existing precedence for identically spelled names and extends it to case variants. To override a generated content type, use _content_type; client defaults still take precedence over it. The winning header's spelling and value are retained for replacements. Cookie authentication uses the canonical Cookie spelling and appends its value. Values containing legitimate comma-separated lists are not split or deduplicated. This does not remove duplicate values inside a header or change the handling of repeated fields supplied directly to the transport.

Metadata

Release files for stract-api 0.10.1

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

Source distribution (sdist)

Source distribution for stract-api 0.10.1
File Size Uploaded Provenance Actions
stract_api-0.10.1.tar.gz 71.2 kB With provenance Details for stract_api-0.10.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stract-api 0.10.1
File Interpreter ABI Platform Actions
stract_api-0.10.1-py3-none-any.whl Python 3 none any Details for stract_api-0.10.1-py3-none-any.whl

Total release size: 215.5 kB

Release files / stract_api-0.10.1.tar.gz

Download URL stract_api-0.10.1.tar.gz
Size 71.2 kB
Tags Source
SHA-256 checksum
How to use checksums
88bb9cef1dd9559ab67509d0fd054c87477ad66da4d117c3c6fcda12aa8272ae
BLAKE2b-256 checksum
How to use checksums
bdf574fc0368c987feefd25332f667966211fd50680b4985b331031c386fa283
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / stract_api-0.10.1-py3-none-any.whl

Download URL stract_api-0.10.1-py3-none-any.whl
Size 144.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c39c9f1256869bb84a76ad324b1e126ed39da14f28c8b3cb4cde5395032ef7cb
BLAKE2b-256 checksum
How to use checksums
bf6d947319b95db7201015d117c7f6a3b0c97a7c37f72cd3de9dbdf25f56e3d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for stract-api 0.10.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for stract_api-0.10.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

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