Skip to main content

Official Python SDK for the extract.design API

Project description

extract-design

Official Python SDK for the extract.design API - AI-powered design extraction for print-on-demand sellers.

Installation

pip install extract-design

Quick Start

from extract_design import ExtractDesign

# Initialize the client
client = ExtractDesign(api_key="sk_live_...")

# Extract a design and wait for completion
result = client.extract_and_wait(
    image_url="https://example.com/product.jpg"
)

print(result.extraction_url)

Usage

Submit an Extraction

from extract_design import ExtractDesign

client = ExtractDesign(api_key="sk_live_...")

# Submit and get extraction ID
response = client.extract(
    image_url="https://example.com/product.jpg"
)

print(f"Extraction ID: {response.extraction_id}")
print(f"Status: {response.status}")
print(f"Estimated time: {response.estimated_time_seconds}s")

Check Extraction Status

result = client.get_extraction(extraction_id)

if result.status == "completed":
    print(f"Design URL: {result.extraction_url}")
elif result.status == "failed":
    print(f"Error: {result.error}")

Wait for Completion

# Simple wait
result = client.wait_for_completion(extraction_id)

# With progress callback
result = client.wait_for_completion(
    extraction_id,
    on_progress=lambda r: print(f"Status: {r.status}"),
)

# Custom timeout and interval
result = client.wait_for_completion(
    extraction_id,
    timeout=120,  # 2 minutes
    interval=3,   # Check every 3 seconds
)

Extract with Options

# With upscaling
result = client.extract_and_wait(
    image_url="https://example.com/product.jpg",
    scale=4,
)

# With remix prompt
result = client.extract_and_wait(
    image_url="https://example.com/product.jpg",
    remix_prompt="Make it a watermelon",
)

# With webhook notification (Pro+ plans)
response = client.extract(
    image_url="https://example.com/product.jpg",
    webhook_url="https://your-api.com/webhook",
    metadata={"order_id": "12345"},
)

Check Usage

usage = client.get_usage()

print(f"Plan: {usage.plan}")
print(f"Credits remaining: {usage.credits.total}")
print(f"Credits used: {usage.credits.used}")

Verify API Key

try:
    client.verify_api_key()
    print("API key is valid")
except AuthenticationError:
    print("Invalid API key")

Error Handling

from extract_design import (
    ExtractDesign,
    AuthenticationError,
    InsufficientCreditsError,
    RateLimitError,
    ValidationError,
    TimeoutError,
    ExtractionFailedError,
)

client = ExtractDesign(api_key="sk_live_...")

try:
    result = client.extract_and_wait(
        image_url="https://example.com/product.jpg"
    )
except AuthenticationError:
    print("Invalid API key")
except InsufficientCreditsError:
    print("Not enough credits")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after} seconds")
except ValidationError as e:
    print(f"Invalid request: {e.error_message}")
except TimeoutError as e:
    print(f"Extraction {e.extraction_id} timed out")
except ExtractionFailedError as e:
    print(f"Extraction failed: {e.reason}")

Context Manager

The client can be used as a context manager to ensure proper cleanup:

with ExtractDesign(api_key="sk_live_...") as client:
    result = client.extract_and_wait(
        image_url="https://example.com/product.jpg"
    )
    print(result.extraction_url)

Configuration

client = ExtractDesign(
    api_key="sk_live_...",
    base_url="https://extract.design",  # Custom base URL
    timeout=60.0,  # Request timeout in seconds
)

Requirements

  • Python 3.10+
  • httpx

License

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

extract_design-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

extract_design-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file extract_design-0.1.0.tar.gz.

File metadata

  • Download URL: extract_design-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for extract_design-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3ad6b177d01f2c049bba75d76647308f23567d167eebdb427b324fe963d91436
MD5 1405081f23d3bcd9586e551ae6462a9d
BLAKE2b-256 d014bc1035af1fcbf32142c164f1077c1f1ad77000707c6b8655e133ee919837

See more details on using hashes here.

File details

Details for the file extract_design-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: extract_design-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for extract_design-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5df9569dbc2c8d842b3e00c6f23ea8603d2348ca17df4590c3693fb596f384f6
MD5 4a856d54b276032cd4596d3222af47cd
BLAKE2b-256 9c4f4e0bb680e1412b70075d2b80913554466daef3746afac46153d87d79e969

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