Skip to main content

splore sdk to interact with splore services

Project description

Splore Python SDK

The Splore Python SDK simplifies the process of interacting with the Splore document processing platform. Use it to upload files, process documents, and retrieve extracted data with minimal setup.


📌 Table of Contents


🚀 Features

  • Agent Management: Create, update, retrieve, and delete agents.
  • File Upload: Upload documents for processing.
  • Extractions: Extract structured data from documents.
  • AWS S3 Integration: Process files directly from S3.
  • Task Monitoring: Track the progress of extraction jobs.
  • Error Handling: Provides meaningful errors and retry mechanisms.

📥 Installation

Install the SDK via pip:

pip install splore-sdk

For optional example dependencies:

pip install splore-sdk[examples]

🏁 Getting Started

Prerequisites

  1. API Key and Base ID: Obtain these from the Splore console.
  2. Python 3.9+: Ensure Python is installed.

Quick Start Example

from splore_sdk import SploreSDK
from time import sleep

# Initialize SDK
sdk = SploreSDK(api_key="YOUR_API_KEY", base_id="YOUR_BASE_ID")

# Get all agents
agents = sdk.agents.get_agents()
agent_id = agents[0]["id"]  # Adjust as needed

# Initialize agent
extraction_agent = sdk.init_agent(agent_id=agent_id)

# use unix based file path.
upload_response = extraction_agent.file_uploader.upload_file(file_path="path/to/file.pdf")

file_id = upload_response.get("fileId")
print("File uploaded with ID:", file_id)

# Start extraction
extraction_agent.extractions.start(file_id=file_id)

# Monitor extraction status
while True:
    status = extraction_agent.extractions.processing_status(file_id=file_id)
    if status.get("fileProcessingStatus") == "COMPLETED":
        break
    sleep(10)  # Wait before checking again

# Retrieve extracted data
extracted_data = extraction_agent.extractions.extracted_response(file_id=file_id)
print("Extracted Data:", extracted_data)

📦 Modules Overview

🔹 Agent Management

Manage agents for document processing.

Example Usage

from splore_sdk import SploreSDK

# Initialize SDK
sdk = SploreSDK(api_key="YOUR_API_KEY", base_id="YOUR_BASE_ID")

# Create an agent
agent_payload = {"name": "Test Agent", "config": {"key": "value"}}
create_response = sdk.create_agent(agent_payload)
print("Create Agent Response:", create_response)

# Get agent details
agent_id = create_response.get("id")
get_response = sdk.agents.get_agents(agentId=agent_id)
print("Get Agent Response:", get_response)

# Get all agents
all_agents = sdk.agents.get_agents()
print("All Agents:", all_agents)

# Update the agent
update_payload = {"name": "Updated Agent Name"}
update_response = sdk.agents.update_agent(agent_payload=update_payload)
print("Update Agent Response:", update_response)

# Delete the agent
delete_response = sdk.agents.delete_agents(agentId=agent_id)
print("Delete Agent Response:", delete_response)

🔹 Extractions

Handle document processing and extraction.

Example Usage

from splore_sdk import SploreSDK

# Initialize SDK
sdk = SploreSDK(api_key="YOUR_API_KEY", base_id="YOUR_BASE_ID")

# Initialize Agent for extraction
extraction_agent = sdk.init_agent(agent_id="YOUR_AGENT_ID")

# Basic extraction flow
extracted_response = extraction_agent.extract(file_path="absolute_file_path")
print(extracted_response)

# advanced extraction flow

# Upload file
with open("sample.pdf", "rb") as file:
    file_response = extraction_agent.file_uploader.upload_file(file)

# store file ids for next steps
file_id = file_response.get("fileId")
print("File uploaded with ID:", file_id)

# Start extraction
start_response = extraction_agent.extractions.start(file_id=file_id)
print("Extraction started:", start_response)

# Check processing status and look for status_response is COMPLETED.
status_response = extraction_agent.extractions.processing_status(file_id=file_id)
print("Processing status:", status_response)

# Get extracted response once status is COMPLETED
extracted_data = extraction_agent.extractions.extracted_response(file_id=file_id)
print("Extracted Data:", extracted_data)

🔹 File Upload

Upload files to Splore for processing.

Example Usage

  • example-1: Open and upload file for extraction
from splore_sdk import SploreSDK

# Initialize SDK
sdk = SploreSDK(api_key="YOUR_API_KEY", base_id="YOUR_BASE_ID")

# use unix based file path.
with open("path/to/your/file.pdf", "rb") as file:
    response = sdk.file_uploader.upload_file(file_stream=file)
    print("Upload Response:", response)
  • example-2: Open and upload file for normal extraction
from splore_sdk import SploreSDK

# Initialize SDK
sdk = SploreSDK(api_key="YOUR_API_KEY", base_id="YOUR_BASE_ID")

metadata = {
    "file_name": "your_file_name", # it will be saved as 
    "customeExtractionEnabled": "false", # it will be uploaded for normal extraction
}
# use unix based file path.
with open("path/to/your/file.pdf", "rb") as file:
    response = sdk.file_uploader.upload_file(file_stream=file, metadata=metadata)
    print("Upload Response:", response)
  • example-3: Open and upload file for other than data points.
from splore_sdk import SploreSDK

# Initialize SDK
sdk = SploreSDK(api_key="YOUR_API_KEY", base_id="YOUR_BASE_ID")
metadata = {
    "file_name": "your_file_name", # it will be saved as 
    "customeExtractionEnabled": "false",
    "isDataFile": "false",  # it will be uploaded as normal file. can't be used for extraction.
}
# use unix based file path.
with open("path/to/your/file.pdf", "rb") as file:
    response = sdk.file_uploader.upload_file(file_stream=file, metadata=metadata)
    print("Upload Response:", response)

🔹 AWS Integration

Download files from AWS S3 for extraction.

Example Usage

from splore_sdk import SploreSDK
from examples.aws import download_from_s3

# Initialize SDK
sdk = SploreSDK(api_key="YOUR_API_KEY", base_id="YOUR_BASE_ID")

# Initialize extraction agent
extraction_agent = sdk.init_agent(agent_id="YOUR_AGENT_ID")

# Create a temporary file destination
file_ref = sdk.file_uploader.create_temp_file_destination(file_extension=".pdf")
s3_uri = "s3://abc/def/abc.pdf"

# Download file from S3
download_from_s3(s3_uri, file_ref)

# Start extraction
response = extraction_agent.extract(file_path=file_ref)
print(response)

⚙️ Advanced Usage

🔸 Polling Interval Configuration

Customize the polling interval for extraction status checks.

while True:
    status = sdk.extractions.processing_status(file_id=file_id)
    if status.get("fileProcessingStatus") == "COMPLETED":
        break
    sleep(5)  # Set custom polling interval

🔸 Error Handling

Handle errors gracefully for better debugging.

try:
    sdk.extractions.upload_file("path/to/file.pdf")
except Exception as e:
    print("Error uploading file:", str(e))

❓ FAQ

1️⃣ How do I get an API Key?

Sign up on the Splore console and navigate to the API section to generate a key.

2️⃣ Can I use this SDK asynchronously?

Asynchronous support will be added in a future release.

3️⃣ Which file formats are supported?

Currently, only PDF files are supported.


🔗 Support

For any questions or issues, please:


📜 License

This SDK is licensed under the MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

splore_sdk-0.1.15.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

splore_sdk-0.1.15-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file splore_sdk-0.1.15.tar.gz.

File metadata

  • Download URL: splore_sdk-0.1.15.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.21.0 CPython/3.13.1 Darwin/23.5.0

File hashes

Hashes for splore_sdk-0.1.15.tar.gz
Algorithm Hash digest
SHA256 4f6825f38d802a408fb8bdd62b490ef22cf58f091d618a122edf59ac83e8acf5
MD5 2ca514ec4e6a087f28d55d7a40d5761f
BLAKE2b-256 1d0206da39994477c250e1cc395c99fb99644233f44cd523c26465f03e4b3fc1

See more details on using hashes here.

File details

Details for the file splore_sdk-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: splore_sdk-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.21.0 CPython/3.13.1 Darwin/23.5.0

File hashes

Hashes for splore_sdk-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 8feadeff70506b66149686d3d1e60aca9a2be21aea4611bbb2fe797cd3eb3edb
MD5 0415ccc91c7f0692ef15d95615e2395d
BLAKE2b-256 665d924325e75e9e1b11df82b225f6d32d3150faf5a7060874243eeb3e393f61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page