Documentation
Python
rowland-sdk for Python
📦 Package Renamed
The Python SDK has been renamed from
rowlandtorowland-sdk. If you have the old package installed, please run:pip uninstall rowland pip install rowland-sdkNo other code changes are needed. If you encounter any issues, please report a bug (opens in a new tab).
- GitHub Repository (opens in a new tab): Source code, examples, and contribution guidelines
- Report an Issue (opens in a new tab): Found a bug or have a feature request? Let us know
Installation
pip install rowland-sdk
Authentication
Get your API key from the Rowland dashboard (opens in a new tab) and set it as an environment variable:
export ROWLAND_API_KEY="your-api-key"
Upload Your First Document
Context Manager
from rowland import DocumentsApiClient
import os
api_key = os.getenv("ROWLAND_API_KEY")
with DocumentsApiClient(api_key=api_key) as client:
with open("lease_agreement.pdf", "rb") as f:
document = client.upload_document(f, "lease_agreement.pdf")
print(f"Document uploaded successfully!")
print(f"ID: {document.id}")
print(f"Status: {document.status}")
Manual Close
from rowland import DocumentsApiClient
import os
api_key = os.getenv("ROWLAND_API_KEY")
client = DocumentsApiClient(api_key=api_key)
try:
with open("lease_agreement.pdf", "rb") as f:
document = client.upload_document(f, "lease_agreement.pdf")
print(f"Document uploaded: {document.id}")
finally:
client.close()
We recommend using the context manager approach as it automatically handles client cleanup.
Check Processing Status
# Get document by ID
document = client.get_document("doc-123")
print(f"Status: {document.status}")
if document.status == "success":
print("Document processing complete!")
elif document.status == "processing":
print("Still processing...")
elif document.status == "failed":
print("Processing failed")
Get Extracted Data
Basic Usage
if document.status == "success":
extractions = client.get_document_extractions(document.id)
print(f"Found {extractions.total_objects_found} objects")
for obj in extractions.consolidated_objects:
print(f"Object type: {obj.get('type')}")
print(f"Data: {obj}")
With Error Handling
from rowland import RowlandHTTPError
try:
if document.status == "success":
extractions = client.get_document_extractions(document.id)
print(f"Found {extractions.total_objects_found} objects")
else:
print(f"Document not ready: {document.status}")
except RowlandHTTPError as e:
print(f"API Error: {e.status_code} - {e.message}")
Response Example
{
"document_id": "123e4567-e89b-12d3-a456-426614174000",
"document_name": "lease_agreement.pdf",
"extraction_id": "ext-456",
"total_objects_found": 3,
"consolidated_objects": [
{
"well_name": "EAGLE FORD SHALE 1H",
"operator": "ABC Energy Corp",
"nri": "0.125",
"interest_type": "Working Interest",
"effective_date": "2024-01-15"
}
]
}
