Skip to main content
The SDK provides methods to retrieve job status, cancel jobs, and list jobs for async operations.

Retrieve Job Status

Get the status and results of an async job:
from pathlib import Path
from reducto import Reducto

client = Reducto()

# Start an async job using run_job()
upload = client.upload(file=Path("document.pdf"))
async_result = client.parse.run_job(input=upload.file_id)
job_id = async_result.job_id

# Retrieve job status
job = client.job.get(job_id)

# Check status
if job.status == "Completed":
    print("Job completed!")
    print(job.result)
elif job.status == "Pending" or job.status == "Idle":
    print("Job still processing...")
elif job.status == "Failed":
    print(f"Job failed: {job.reason}")

Cancel Job

Cancel a running job:
from reducto import Reducto

client = Reducto()

# Start async job
async_result = client.parse.run_job(input=upload.file_id)

# Cancel it
client.job.cancel(async_result.job_id)

List Jobs

Get a list of your jobs with pagination:
from reducto import Reducto

client = Reducto()

# List recent jobs (default: 100 per page, max: 500)
jobs = client.job.get_all()

for job in jobs.jobs:
    print(f"Job {job.job_id}: {job.status}")

# With pagination parameters
jobs = client.job.get_all(
    limit=50,              # Max jobs per page (default: 100, max: 500)
    cursor=None,           # Use next_cursor from previous response
    exclude_configs=True   # Exclude raw_config to reduce response size
)

# Paginate through all jobs
cursor = None
while True:
    jobs = client.job.get_all(cursor=cursor, limit=100)
    for job in jobs.jobs:
        print(f"Job {job.job_id}: {job.status}")
    
    if not jobs.next_cursor:
        break
    cursor = jobs.next_cursor

Parameters

ParameterTypeDefaultDescription
limitint100Maximum jobs per page (max: 500)
cursorstr | NoneNonePagination cursor from previous response
exclude_configsboolFalseExclude raw_config to reduce response size

Polling for Completion

Poll for job completion:
import time
from pathlib import Path
from reducto import Reducto
import reducto

client = Reducto()

# Start async job
upload = client.upload(file=Path("document.pdf"))
async_result = client.parse.run_job(input=upload.file_id)
job_id = async_result.job_id

# Poll until complete
while True:
    job = client.job.get(job_id)
    
    if job.status == "Completed":
        print("Job completed!")
        print(job.result)
        break
    elif job.status == "Failed":
        print(f"Job failed: {job.reason}")
        break
    
    print(f"Status: {job.status}, waiting...")
    time.sleep(2)  # Wait 2 seconds before checking again

Job Status Values

StatusDescription
PendingJob is queued, waiting for a worker
IdleJob is idle, waiting to be picked up
CompletedResults are ready
FailedProcessing failed (check job.reason for details)

Error Handling

from reducto import Reducto
import reducto

try:
    job = client.job.get(job_id)
except reducto.NotFoundError:
    print("Job not found")
except reducto.APIConnectionError as e:
    print(f"Connection failed: {e}")
except reducto.APIStatusError as e:
    print(f"Error: {e.status_code} - {e.response}")

Next Steps