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:
- Node (JavaScript / TypeScript):
stract-apion npm - Java (17+):
com.stract-api:stract-apion Maven Central
This Python package is automatically generated by the OpenAPI Generator project:
- API version: 0.9.5
- Package version: 0.9.5
- 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
- Account
- AccountCreditCache
- AccountCreditLedger
- AccountUser
- AccountUserRole
- ApiKey
- Catalog
- CreateAccountUserRequest
- CreateCatalogRequest
- CreateFieldRequest
- CreateJobRequest
- CreateStructRequest
- DeletedDocument
- DeletedField
- Document
- DocumentLink
- DocumentProcessingStatus
- DocumentText
- EditAccountRequest
- EditFieldRequest
- EditMyUserRequest
- FieldType
- Job
- JobDocument
- JobOutput
- JobOutputRecord
- JobStatus
- LlmModel
- LoginRequest
- LoginResponse
- ModelField
- Struct
- SyncTextJobRequest
- UploadTextDocumentRequest
- User
Documentation For Authorization
Authentication schemes defined for the API:
bearerAuth
- Type: Bearer authentication
Author
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:
_headers(within one dict, the last inserted case variant wins).- Explicit OpenAPI header parameters and generated
Content-Type(or_content_type). GeneratedAcceptis added only when neither_headersnor explicit header parameters contain anAcceptcase variant. ApiClient.default_headers(including headers set withset_default_header).- The client's
cookiesetting, forCookie. - Authentication headers. A non-empty
_request_authreplaces configured authentication for that call;{}retains configured authentication. Cookie authentication appends to the selectedCookievalue.
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.9.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stract_api-0.9.5.tar.gz | 65.6 kB | With provenance | Details for stract_api-0.9.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stract_api-0.9.5-py3-none-any.whl | Python 3 | none | any | Details for stract_api-0.9.5-py3-none-any.whl |
Total release size: 187.5 kB
Release files / stract_api-0.9.5.tar.gz
| Download URL | stract_api-0.9.5.tar.gz |
|---|---|
| Size | 65.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a610446ee32515282feeefff188788a47c6e35ea914fcf7422ea5b92f2d53cd
|
|
BLAKE2b-256 checksum How to use checksums |
a0ca4dcae35169fe62999c4edb84c2aa0404dd310d50222ab5f74b0c4cfc7aa6
|
| 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 logRelease files / stract_api-0.9.5-py3-none-any.whl
| Download URL | stract_api-0.9.5-py3-none-any.whl |
|---|---|
| Size | 122.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
537af7de7afbc392c9a6926d20d08c49959e87d1a8c62a7f6e7df4d6e3262841
|
|
BLAKE2b-256 checksum How to use checksums |
83fb9ea94e1a914e4e56d7583d95b07b8a5f3508f34e2f3b7ba1415c70607bb7
|
| 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 logSecurity for stract-api 0.9.5
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.
Attestation for stract_api-0.9.5.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 logA 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.