Skip to main content

Official FlexOps Platform Python SDK - multi-carrier shipping, order management, and logistics API

Project description

FlexOps Python SDK

Official Python SDK for the FlexOps multi-carrier shipping platform.

Installation

pip install flexops

Quick Start

from flexops import FlexOps

# API key authentication (recommended for server-to-server)
client = FlexOps(
    api_key="fxk_live_...",
    workspace_id="ws_abc123",
)

# Get shipping rates from all carriers
rates = client.shipping.get_rates({
    "fromZip": "10001",
    "toZip": "90210",
    "weight": 16,
    "weightUnit": "oz",
})

# Create a label with the cheapest rate
label = client.shipping.create_label({
    "carrier": rates["data"][0]["carrier"],
    "service": rates["data"][0]["service"],
    "fromAddress": {
        "name": "Warehouse",
        "street1": "123 Main St",
        "city": "New York",
        "state": "NY",
        "zip": "10001",
        "country": "US",
    },
    "toAddress": {
        "name": "Customer",
        "street1": "456 Oak Ave",
        "city": "Los Angeles",
        "state": "CA",
        "zip": "90210",
        "country": "US",
    },
    "parcel": {"weight": 16, "weightUnit": "oz"},
})

# Track a shipment
tracking = client.shipping.track("9400111899223456789012")

Authentication

API Key (recommended)

client = FlexOps(api_key="fxk_live_...", workspace_id="ws_abc123")

Email / Password

client = FlexOps(base_url="https://gateway.flexops.io")
client.auth.login("user@example.com", "password")
client.workspace_id = "ws_abc123"

Direct Carrier Operations

Access carrier-specific endpoints when you need full control:

# USPS domestic label
label = client.carriers.usps.create_domestic_label({
    "imageType": "PDF",
    "mailClass": "PRIORITY_MAIL",
    "weightInOunces": 16,
    # ... full USPS payload
})

# FedEx rate quote
rates = client.carriers.fedex.get_rates({...})

# UPS tracking
info = client.carriers.ups.track({"trackingNumber": "1Z999AA10123456784"})

# DHL shipment
shipment = client.carriers.dhl.create_shipment({...})

Webhook Verification

from flexops import WebhooksResource

is_valid = WebhooksResource.verify_signature(
    payload=request.body.decode(),
    signature=request.headers["X-FlexOps-Signature"],
    secret="whsec_...",
)

Curl Quickstart

Every SDK method is a thin wrapper around the FlexOps REST API. If you want to verify the API before committing to the SDK — or you're integrating from a language we don't ship a SDK for — these curl invocations hit the same endpoints:

# Shop rates across all connected carriers
curl -X POST https://gateway.flexops.io/api/workspaces/ws_abc123/shipping/rates \
  -H "X-API-Key: fxk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "fromAddress": {"street1": "123 Main St", "city": "New York", "state": "NY", "zip": "10001", "country": "US"},
    "toAddress":   {"street1": "456 Oak Ave", "city": "Los Angeles", "state": "CA", "zip": "90210", "country": "US"},
    "parcel":      {"weight": 16, "weightUnit": "oz"}
  }'

# Create a label
curl -X POST https://gateway.flexops.io/api/workspaces/ws_abc123/shipping/labels \
  -H "X-API-Key: fxk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "carrier":  "USPS",
    "service":  "PRIORITY_MAIL",
    "fromAddress": {"name": "Warehouse", "street1": "123 Main St", "city": "New York", "state": "NY", "zip": "10001", "country": "US"},
    "toAddress":   {"name": "Customer",  "street1": "456 Oak Ave", "city": "Los Angeles", "state": "CA", "zip": "90210", "country": "US"},
    "parcel":   {"weight": 16, "weightUnit": "oz"}
  }'

# Track a shipment
curl https://gateway.flexops.io/api/workspaces/ws_abc123/shipping/track/9400111899223456789012 \
  -H "X-API-Key: fxk_live_..."

# Cancel a label (via the unified carrier-agnostic endpoint)
curl -X DELETE https://gateway.flexops.io/api/v3.0/shipping/Usps/cancel/9400111899223456789012 \
  -H "X-API-Key: fxk_live_..."

Use an fxk_test_... key instead of fxk_live_... to hit the sandbox environment; mock carriers respond, no real charges, no real labels.

Resources

Resource Methods Description
client.auth 10 Login, register, password management
client.workspaces 8 Workspace CRUD, membership
client.shipping 12 Rate shopping, labels, tracking, batch
client.carriers 76 USPS, UPS, FedEx, DHL direct endpoints
client.webhooks 8 Subscription CRUD, signature verification
client.wallet 4 Balance, transactions, auto-reload
client.insurance 5 Quotes, purchase, claims
client.returns 9 RMA lifecycle management
client.api_keys 4 Key creation, rotation, revocation
client.analytics 16 Shipments, orders, carrier analytics
client.orders 12 Order management
client.inventory 5 Warehouse inventory
client.pickups 4 Carrier pickup scheduling
client.scan_forms 3 USPS scan forms
client.rules 6 Shipping automation rules

Configuration

client = FlexOps(
    base_url="https://gateway.flexops.io",  # API base URL
    api_key="fxk_live_...",              # API key auth
    workspace_id="ws_abc123",            # Default workspace
    timeout=30.0,                        # Request timeout (seconds)
    headers={"X-Custom": "value"},       # Custom headers
    retry={                              # Retry configuration
        "max_retries": 3,
        "base_delay": 1.0,
    },
)

Requirements

  • Python 3.10+
  • requests >= 2.31
  • pydantic >= 2.0

License

Proprietary - FlexOps, LLC

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

flexops-1.0.0.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

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

flexops-1.0.0-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file flexops-1.0.0.tar.gz.

File metadata

  • Download URL: flexops-1.0.0.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for flexops-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5f0a0aa8a50af3e93c7bdfbd8533924fee2d4da8cfb7c079c96a8c954a345857
MD5 ecf484290887e3d0586c2068b5eecd93
BLAKE2b-256 050be8c049b57255d9935e0e2e9db8da2d43ce05d4d44335ae82240987a77bde

See more details on using hashes here.

File details

Details for the file flexops-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: flexops-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 33.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for flexops-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 426f2467ac87f038b96d745099206e2bfc819754d649133edd0e300ee8a9f3f1
MD5 3e1461e61f899e0323c28278f5bce435
BLAKE2b-256 9892d2e7025496a8e40fbd7e1b3f234baa7f01a0718aaa08559a639f021188fb

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