Rowland LogoRowland

Python

Rowland SDK for Python

Installation

pip install rowland

Authentication

Get your API key from the Rowland dashboard and set it as an environment variable:

export ROWLAND_API_KEY="your-api-key"

Upload Your First Document

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}")
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

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}")
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"
    }
  ]
}