Skip to main content

Official Python SDK for the AgentRef Affiliate API

Project description

AgentRef Python SDK

Official Python SDK for the AgentRef REST API v1.

Install

pip install agentref

Quickstart

from agentref import AgentRef

client = AgentRef(api_key="ak_live_...")
programs = client.programs.list()
print(programs.meta.request_id)

Async quickstart

from agentref import AsyncAgentRef

async with AsyncAgentRef(api_key="ak_live_...") as client:
    programs = await client.programs.list()

Authentication

  • Uses Authorization: Bearer <key>.
  • Supports ak_live_*, ak_aff_*, ak_onb_*.
  • Provide api_key directly or set AGENTREF_API_KEY.

Resources

  • client.programs: list, list_all, get, create, update, delete, stats, list_affiliates, list_coupons, create_coupon, create_invite
  • client.affiliates: list, get, approve, block, unblock
  • client.conversions: list, stats, recent
  • client.payouts: list, list_pending, stats
  • client.flags: list, stats, resolve
  • client.billing: current, tiers, subscribe
  • client.merchant: get, domain_status

Pagination

List endpoints return PaginatedResponse[T] with:

  • meta.total
  • meta.page
  • meta.page_size
  • meta.has_more
  • meta.next_cursor
  • meta.request_id

Auto-pagination (list_all) stops on has_more is False.

Idempotency and retry behavior

  • GET/HEAD: auto-retry on 429/5xx.
  • POST: auto-retry only when idempotency_key is provided.
  • PATCH/DELETE: never auto-retry.
  • Idempotency-Key header is sent only for POST requests.

Error handling

from agentref import AgentRef
from agentref.errors import ForbiddenError, NotFoundError, RateLimitError, AgentRefError

client = AgentRef(api_key="ak_live_...")

try:
    client.programs.get("missing-id")
except ForbiddenError as e:
    print(e.code, e.request_id)
except NotFoundError as e:
    print(e.request_id)
except RateLimitError as e:
    print(e.retry_after)
except AgentRefError as e:
    print(e.status)

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

agentref-1.0.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

agentref-1.0.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agentref-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d805505eb5e121943f3fe52c7dc3369c87b023742fbc74510a984f8b4eaaf89f
MD5 d82dd913fedd34b3a7a88729b3a34544
BLAKE2b-256 b7a2e4733fe641d63f012fbef02502c256d3d996e98e7c2524ecf3621a62a229

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for agentref-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c56309e0b4f42fb84cd99c399443051615c46e30dc790e077f035eb8e7fb54ab
MD5 a9f7189cdd1a567cd0c634f87caa2219
BLAKE2b-256 860757f5f644cda1fcc9699d1fcfa07da3a21fb246d91b3fbaa2da6c5af21283

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