Skip to main content

stract-api-python

Get structured output from unstructured inputs

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.9.4
  • Package version: 0.1.0
  • 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 information about user's account
AccountApi get_account_users GET /account/user Get the users in the current account
AccountCreditLedgerApi get_account_credit_ledger_for_spending_user GET /account_credit_ledger Get the account credit ledger
ApiKeyApi get_api_keys GET /api-key Get the current 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 Get all catalogs
CreditsApi get_current_credits GET /current_credits Get the current credit balance
CreditsApi get_current_org_credits GET /current_org_credits Get the current organization credit balance
DocumentApi delete_document DELETE /document/{documentId} Delete a document
DocumentApi get_catalog_documents GET /catalog/{catalogId}/document Get documents for a catalog
DocumentApi get_document_link GET /document/{documentId}/link Get a link to a document
DocumentApi get_document_text GET /catalog/{catalogId}/document/{documentId}/text Get the extracted text of a document
DocumentApi get_documents_for_job GET /job/{jobId}/document Get the documents for a job
DocumentApi get_user_documents GET /document Get all documents for the user
DocumentApi upload_document POST /catalog/{catalogId}/document Upload a file to the specified catalog
DocumentApi upload_document_no_catalog POST /document Upload a document
DocumentApi upload_text_document POST /catalog/{catalogId}/document/text Upload text as a document to the specified catalog
DocumentApi upload_text_document_no_catalog POST /document/text Upload text as a document
FieldApi create_fields POST /struct/{structId}/field Create fields for 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 Get data fields for 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 a job
JobApi get_job_by_id GET /job/{jobId} Get a job by ID
JobApi get_job_output_csv GET /job/{jobId}/output_csv Get the output for a job as CSV
JobApi get_job_output_json GET /job/{jobId}/output_json Get the output for a job as JSON
JobApi get_struct_jobs GET /struct/{structId}/job Get all jobs for the specified struct
JobApi get_user_jobs GET /job Get all jobs for the user
JobApi upload_document_process_and_run_job POST /struct/{structId}/job/sync Upload a document, run an analysis job on that document, and download the output. For API use.
JobApi upload_text_document_and_run_job POST /struct/{structId}/job/sync/text Create a document from text, run an analysis job on that document, and download the output. For API use.
JobDocumentApi get_job_document_output GET /job_document/{jobDocId}/output Get the output for a job document
JobDocumentApi get_job_documents GET /job/{jobId}/job_document Get the status of document analysis in a job
LlmModelApi get_llm_models GET /llm_model Get the available LLM models
StructApi archive_struct POST /struct/{structId}/archive Archive a struct
StructApi create_struct POST /struct Create a new data structure
StructApi get_structs GET /struct Get all data structures
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.1.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 stract-api 0.1.0
File Size Uploaded Provenance Actions
stract_api-0.1.0.tar.gz 65.4 kB With provenance Details for stract_api-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 187.2 kB

Release files / stract_api-0.1.0.tar.gz

Download URL stract_api-0.1.0.tar.gz
Size 65.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f9f302a67f450a50e71eb59403dff1da6d800bbbd6bc759386fc74e8bee67b2e
BLAKE2b-256 checksum
How to use checksums
a08c2be85c30b460561e1495f8844c9146b76bdf46a7e9bca987202231a090ed
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 12, 2026.

Transparency log

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

Download URL stract_api-0.1.0-py3-none-any.whl
Size 121.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db6cfb7acd196a62d62551a261341c1cd0875d39ee2666de443782a9c22f6363
BLAKE2b-256 checksum
How to use checksums
15959da4767d4188c0f65aea151dd5b9a976be046bb4f562a08388050c54ff5c
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 12, 2026.

Transparency log

Security for stract-api 0.1.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.

Full provenance

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

Select from 2 files

Attestation for stract_api-0.1.0.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 12, 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