Rapidata Python Client

3.8.0 · active · verified Thu Apr 16

The `rapidata` package provides a Python client to easily interact with the Rapidata Web API, enabling users to programmatically request human annotation for their data. It simplifies creating and managing orders for various human-in-the-loop tasks. The current version is 3.8.0, and the library appears to be under active development with regular updates, supporting Python 3.10 and newer.

Common errors

Warnings

Install

Imports

Quickstart

Initializes the `RapidataClient` for interacting with the API. It demonstrates both interactive login (which opens a browser for authentication) and programmatic authentication using `client_id` and `client_secret` environment variables or direct arguments. Once authenticated, the client provides managers for `order` and `validation` operations. An illustrative (commented out) example of creating a compare order is included to show typical usage, noting that actual data points and valid URLs are required.

import os
from rapidata import RapidataClient

# Option 1: Interactive login (opens browser)
# client = RapidataClient()

# Option 2: Using client ID and secret (recommended for automation)
client_id = os.environ.get('RAPIDATA_CLIENT_ID', 'your_client_id_here')
client_secret = os.environ.get('RAPIDATA_CLIENT_SECRET', 'your_client_secret_here')

if client_id == 'your_client_id_here' or client_secret == 'your_client_secret_here':
    print("Please set RAPIDATA_CLIENT_ID and RAPIDATA_CLIENT_SECRET environment variables or replace placeholders.")
    # Fallback to interactive login for demonstration if env vars are not set
    # client = RapidataClient() # Uncomment for interactive flow if env vars are missing
else:
    client = RapidataClient(client_id=client_id, client_secret=client_secret)

# Example: Create a simple compare order (requires actual data and context)
# This is a placeholder as full order creation requires specific data inputs
try:
    # This part is illustrative as it requires actual data (datapoints) and URLs
    # order_name = "My Example Alignment Order"
    # instruction = "Which image matches the description better?"
    # contexts = ["A small blue book sitting on a large red book."]
    # datapoints = [["https://example.com/image1.jpg", "https://example.com/image2.jpg"]]
    # order = client.order.create_compare_order(
    #     name=order_name,
    #     instruction=instruction,
    #     contexts=contexts,
    #     datapoints=datapoints
    # )
    # print(f"Order created: {order.name} (ID: {order.id})")
    print("RapidataClient initialized. You can now use client.order, client.validation, etc.")
except Exception as e:
    print(f"Could not create order example (requires valid credentials and data): {e}")

# To reset credentials saved locally:
# client.reset_credentials()

view raw JSON →