Metadata-Version: 2.4
Name: stract_api
Version: 0.9.5
Summary: Stract API
Home-page: 
Author: Matt
Author-email: Matt <matt@stract-api.com>
License: MIT
Project-URL: Repository, https://github.com/mattpmoreno/stract-api-python
Keywords: OpenAPI,OpenAPI-Generator,Stract API
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: urllib3<3.0.0,>=2.7.0
Requires-Dist: python-dateutil>=2.8.2
Requires-Dist: pydantic>=2.11
Requires-Dist: typing-extensions>=4.7.1
Dynamic: author
Dynamic: license-file

# 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-api` on npm](https://www.npmjs.com/package/stract-api)
- **Java (17+)**: [`com.stract-api:stract-api` on Maven Central](https://central.sonatype.com/artifact/com.stract-api/stract-api)


This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) 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:

```sh
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:
```python
import stract_api
```

### Setuptools

Install via [Setuptools](http://pypi.python.org/pypi/setuptools).

```sh
python setup.py install --user
```
(or `sudo python setup.py install` to install the package for all users)

Then import the package:
```python
import stract_api
```

### Tests

Execute `pytest` to run the tests.

## Getting Started

Please follow the [installation procedure](#installation--usage) and then run the following:

```python

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**](docs/AccountApi.md#create_account_user) | **POST** /account/user | Add a user to the current account
*AccountApi* | [**edit_account**](docs/AccountApi.md#edit_account) | **PUT** /account | Edit the current account
*AccountApi* | [**get_account**](docs/AccountApi.md#get_account) | **GET** /account | Get information about user&#39;s account
*AccountApi* | [**get_account_users**](docs/AccountApi.md#get_account_users) | **GET** /account/user | Get the users in the current account
*AccountCreditLedgerApi* | [**get_account_credit_ledger_for_spending_user**](docs/AccountCreditLedgerApi.md#get_account_credit_ledger_for_spending_user) | **GET** /account_credit_ledger | Get the account credit ledger
*ApiKeyApi* | [**get_api_keys**](docs/ApiKeyApi.md#get_api_keys) | **GET** /api-key | Get the current account&#39;s API keys
*CatalogApi* | [**create_catalog**](docs/CatalogApi.md#create_catalog) | **POST** /catalog | Create a catalog
*CatalogApi* | [**delete_catalog**](docs/CatalogApi.md#delete_catalog) | **DELETE** /catalog/{catalogId} | Delete a catalog
*CatalogApi* | [**get_catalogs**](docs/CatalogApi.md#get_catalogs) | **GET** /catalog | Get all catalogs
*CreditsApi* | [**get_current_credits**](docs/CreditsApi.md#get_current_credits) | **GET** /current_credits | Get the current credit balance
*CreditsApi* | [**get_current_org_credits**](docs/CreditsApi.md#get_current_org_credits) | **GET** /current_org_credits | Get the current organization credit balance
*DocumentApi* | [**delete_document**](docs/DocumentApi.md#delete_document) | **DELETE** /document/{documentId} | Delete a document
*DocumentApi* | [**get_catalog_documents**](docs/DocumentApi.md#get_catalog_documents) | **GET** /catalog/{catalogId}/document | Get documents for a catalog
*DocumentApi* | [**get_document_link**](docs/DocumentApi.md#get_document_link) | **GET** /document/{documentId}/link | Get a link to a document
*DocumentApi* | [**get_document_text**](docs/DocumentApi.md#get_document_text) | **GET** /catalog/{catalogId}/document/{documentId}/text | Get the extracted text of a document
*DocumentApi* | [**get_documents_for_job**](docs/DocumentApi.md#get_documents_for_job) | **GET** /job/{jobId}/document | Get the documents for a job
*DocumentApi* | [**get_user_documents**](docs/DocumentApi.md#get_user_documents) | **GET** /document | Get all documents for the user
*DocumentApi* | [**upload_document**](docs/DocumentApi.md#upload_document) | **POST** /catalog/{catalogId}/document | Upload a file to the specified catalog
*DocumentApi* | [**upload_document_no_catalog**](docs/DocumentApi.md#upload_document_no_catalog) | **POST** /document | Upload a document
*DocumentApi* | [**upload_text_document**](docs/DocumentApi.md#upload_text_document) | **POST** /catalog/{catalogId}/document/text | Upload text as a document to the specified catalog
*DocumentApi* | [**upload_text_document_no_catalog**](docs/DocumentApi.md#upload_text_document_no_catalog) | **POST** /document/text | Upload text as a document
*FieldApi* | [**create_fields**](docs/FieldApi.md#create_fields) | **POST** /struct/{structId}/field | Create fields for a struct
*FieldApi* | [**delete_field**](docs/FieldApi.md#delete_field) | **DELETE** /field/{fieldId} | Delete a field
*FieldApi* | [**edit_field**](docs/FieldApi.md#edit_field) | **PUT** /field/{fieldId} | Edit a field
*FieldApi* | [**get_fields**](docs/FieldApi.md#get_fields) | **GET** /struct/{structId}/field | Get data fields for a struct
*JobApi* | [**archive_job**](docs/JobApi.md#archive_job) | **POST** /job/{jobId}/archive | Archive a job
*JobApi* | [**cancel_job**](docs/JobApi.md#cancel_job) | **POST** /job/{jobId}/cancel | Cancel a job
*JobApi* | [**create_job**](docs/JobApi.md#create_job) | **POST** /struct/{structId}/job | Create a job
*JobApi* | [**get_job_by_id**](docs/JobApi.md#get_job_by_id) | **GET** /job/{jobId} | Get a job by ID
*JobApi* | [**get_job_output_csv**](docs/JobApi.md#get_job_output_csv) | **GET** /job/{jobId}/output_csv | Get the output for a job as CSV
*JobApi* | [**get_job_output_json**](docs/JobApi.md#get_job_output_json) | **GET** /job/{jobId}/output_json | Get the output for a job as JSON
*JobApi* | [**get_struct_jobs**](docs/JobApi.md#get_struct_jobs) | **GET** /struct/{structId}/job | Get all jobs for the specified struct
*JobApi* | [**get_user_jobs**](docs/JobApi.md#get_user_jobs) | **GET** /job | Get all jobs for the user
*JobApi* | [**upload_document_process_and_run_job**](docs/JobApi.md#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**](docs/JobApi.md#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**](docs/JobDocumentApi.md#get_job_document_output) | **GET** /job_document/{jobDocId}/output | Get the output for a job document
*JobDocumentApi* | [**get_job_documents**](docs/JobDocumentApi.md#get_job_documents) | **GET** /job/{jobId}/job_document | Get the status of document analysis in a job
*LlmModelApi* | [**get_llm_models**](docs/LlmModelApi.md#get_llm_models) | **GET** /llm_model | Get the available LLM models
*StructApi* | [**archive_struct**](docs/StructApi.md#archive_struct) | **POST** /struct/{structId}/archive | Archive a struct
*StructApi* | [**create_struct**](docs/StructApi.md#create_struct) | **POST** /struct | Create a new data structure
*StructApi* | [**get_structs**](docs/StructApi.md#get_structs) | **GET** /struct | Get all data structures
*UserApi* | [**edit_my_user**](docs/UserApi.md#edit_my_user) | **PUT** /my_user | Edit the current user
*UserApi* | [**get_my_user**](docs/UserApi.md#get_my_user) | **GET** /my_user | Get the current user


## Documentation For Models

 - [Account](docs/Account.md)
 - [AccountCreditCache](docs/AccountCreditCache.md)
 - [AccountCreditLedger](docs/AccountCreditLedger.md)
 - [AccountUser](docs/AccountUser.md)
 - [AccountUserRole](docs/AccountUserRole.md)
 - [ApiKey](docs/ApiKey.md)
 - [Catalog](docs/Catalog.md)
 - [CreateAccountUserRequest](docs/CreateAccountUserRequest.md)
 - [CreateCatalogRequest](docs/CreateCatalogRequest.md)
 - [CreateFieldRequest](docs/CreateFieldRequest.md)
 - [CreateJobRequest](docs/CreateJobRequest.md)
 - [CreateStructRequest](docs/CreateStructRequest.md)
 - [DeletedDocument](docs/DeletedDocument.md)
 - [DeletedField](docs/DeletedField.md)
 - [Document](docs/Document.md)
 - [DocumentLink](docs/DocumentLink.md)
 - [DocumentProcessingStatus](docs/DocumentProcessingStatus.md)
 - [DocumentText](docs/DocumentText.md)
 - [EditAccountRequest](docs/EditAccountRequest.md)
 - [EditFieldRequest](docs/EditFieldRequest.md)
 - [EditMyUserRequest](docs/EditMyUserRequest.md)
 - [FieldType](docs/FieldType.md)
 - [Job](docs/Job.md)
 - [JobDocument](docs/JobDocument.md)
 - [JobOutput](docs/JobOutput.md)
 - [JobOutputRecord](docs/JobOutputRecord.md)
 - [JobStatus](docs/JobStatus.md)
 - [LlmModel](docs/LlmModel.md)
 - [LoginRequest](docs/LoginRequest.md)
 - [LoginResponse](docs/LoginResponse.md)
 - [ModelField](docs/ModelField.md)
 - [Struct](docs/Struct.md)
 - [SyncTextJobRequest](docs/SyncTextJobRequest.md)
 - [UploadTextDocumentRequest](docs/UploadTextDocumentRequest.md)
 - [User](docs/User.md)


<a id="documentation-for-authorization"></a>
## Documentation For Authorization


Authentication schemes defined for the API:
<a id="bearerAuth"></a>
### 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.
