Official Python client library for the Penpoint API
Project description
Penpoint Python Client
Official Python client library for the Penpoint API. This library provides a simple and intuitive interface for interacting with Penpoint's document processing and reference search capabilities.
Features
- File Management: Upload, list, update, and delete files
- Discrete References: Search documents with three levels of precision (Basic, Standard, Advanced)
- File Markup: Generate marked-up versions of documents with highlighted references
- Type Safety: Full type hints and modern Python support
- Async Support: Both synchronous and asynchronous client interfaces
Installation
pip install penpoint
Quick Start
from penpoint import PenpointClient
# Initialize the client with your API key
client = PenpointClient(api_key="your_api_key_here")
# Upload a file
with open("document.pdf", "rb") as f:
file_obj = client.files.upload(
file=f,
filename="document.pdf",
summary="A sample document for testing"
)
# Search for references
references = client.discrete_references.basic(
file_id=file_obj.id,
prompt="CMake integration",
markup_file=True,
markup_color="#362580"
)
print(f"Found {len(references.parts)} references")
API Reference
Authentication
All API requests require an API key, which should be passed as the x-api-key header.
Files
List Files
files = client.files.list(limit=20, offset=0)
Upload File
file_obj = client.files.upload(
file=file_handle,
filename="document.pdf",
summary="Document description"
)
Update File
updated_file = client.files.update(
file_id=123,
summary="Updated description",
expiration_date="2025-12-31"
)
Delete File
client.files.delete(file_id=123)
Discrete References
Basic Search
references = client.discrete_references.basic(
file_id=123,
prompt="search term",
markup_file=True,
markup_color="#FF0000"
)
Standard Search
references = client.discrete_references.standard(
file_id=123,
prompt="search term",
markup_file=True,
markup_color="#FF0000"
)
Advanced Search
references = client.discrete_references.advanced(
file_id=123,
prompt="search term",
markup_file=True,
markup_color="#FF0000"
)
Configuration
The client can be configured with various options:
from penpoint import PenpointClient
client = PenpointClient(
api_key="your_api_key",
base_url="https://api.penpoint.ai/v1", # Default
timeout=30, # Request timeout in seconds
max_retries=3 # Maximum retry attempts
)
Error Handling
The library provides comprehensive error handling:
from penpoint import PenpointError, PenpointAPIError
try:
files = client.files.list()
except PenpointAPIError as e:
print(f"API Error: {e.status_code} - {e.message}")
except PenpointError as e:
print(f"Client Error: {e}")
Async Support
For asynchronous applications, use the async client:
from penpoint import AsyncPenpointClient
import asyncio
async def main():
client = AsyncPenpointClient(api_key="your_api_key")
files = await client.files.list()
print(f"Found {len(files.data)} files")
asyncio.run(main())
Development
Setup
git clone https://github.com/penpoint/penpoint-python.git
cd penpoint-python
pip install -e ".[dev]"
Running Tests
pytest
Code Formatting
black penpoint/
flake8 penpoint/
mypy penpoint/
Publishing
cd python
make build # Build the package
make publish # Publish to PyPI (requires twine setup)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Documentation: https://penpoint-python.readthedocs.io/
- Issues: https://github.com/penpoint/penpoint-python/issues
- API Reference: https://api.penpoint.ai/docs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file penpoint-0.1.0.tar.gz.
File metadata
- Download URL: penpoint-0.1.0.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67e753c66056544d2e0bf3c2a8f775153561b6efb3ef6802daf30095897a4c34
|
|
| MD5 |
c3442478c7556727c030796362e6fe29
|
|
| BLAKE2b-256 |
7d1ac53faac24f67034b3515b3a9e6cb668ebb03a883621e921a7e53976dd1d6
|
Provenance
The following attestation bundles were made for penpoint-0.1.0.tar.gz:
Publisher:
deploy-pypi.yml on penpointai/penpoint-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
penpoint-0.1.0.tar.gz -
Subject digest:
67e753c66056544d2e0bf3c2a8f775153561b6efb3ef6802daf30095897a4c34 - Sigstore transparency entry: 1134742551
- Sigstore integration time:
-
Permalink:
penpointai/penpoint-python@0f201b75f82ff0e98b0f422f6aa1c500265a3483 -
Branch / Tag:
refs/heads/pypi - Owner: https://github.com/penpointai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy-pypi.yml@0f201b75f82ff0e98b0f422f6aa1c500265a3483 -
Trigger Event:
push
-
Statement type:
File details
Details for the file penpoint-0.1.0-py3-none-any.whl.
File metadata
- Download URL: penpoint-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
154367787e359682b3b505b4a362115ea020dfcc7feee72b15089703bbfb8d7c
|
|
| MD5 |
2e8ec7955238a11e8a0666b83fbcf19b
|
|
| BLAKE2b-256 |
dfd056b460c53946f03e6dabcde6afd0d26a0b9a6cfe703d62c48e98e11c0de1
|
Provenance
The following attestation bundles were made for penpoint-0.1.0-py3-none-any.whl:
Publisher:
deploy-pypi.yml on penpointai/penpoint-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
penpoint-0.1.0-py3-none-any.whl -
Subject digest:
154367787e359682b3b505b4a362115ea020dfcc7feee72b15089703bbfb8d7c - Sigstore transparency entry: 1134742558
- Sigstore integration time:
-
Permalink:
penpointai/penpoint-python@0f201b75f82ff0e98b0f422f6aa1c500265a3483 -
Branch / Tag:
refs/heads/pypi - Owner: https://github.com/penpointai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy-pypi.yml@0f201b75f82ff0e98b0f422f6aa1c500265a3483 -
Trigger Event:
push
-
Statement type: