Skip to main content

SDKs

Official client libraries for the Affilync API. Every SDK shares the same design — typed responses, auto-pagination, automatic retries, and webhook verification — so the concepts below apply no matter which language you pick.

Install

LanguagePackageInstall
Node.js / TypeScript@affilync/sdknpm install @affilync/sdk
Pythonaffilyncpip install affilync
Rubyaffilyncgem install affilync
PHPaffilync/sdkcomposer require affilync/sdk
Gogithub.com/affilync/go-sdkgo get github.com/affilync/go-sdk
.NET / C#Affilync.SDKdotnet add package Affilync.SDK

Quick start

Grab an API key from your API settings, then create a client and make your first call.

Node.js / TypeScript

import Affilync from '@affilync/sdk';

const client = new Affilync('af_live_...');

const campaign = await client.campaigns.create({
name: 'My Campaign',
type: 'affiliate',
commission_type: 'percentage',
commission_rate: 0.15,
});

Python

import affilync

client = affilync.Affilync(api_key="af_live_...")

campaign = client.campaigns.create(
name="My Campaign",
type="affiliate",
commission_type="percentage",
commission_rate=0.15,
)

Ruby

require 'affilync'

client = Affilync::Client.new(api_key: 'af_live_...')

campaign = client.campaigns.create(
name: 'My Campaign',
type: 'affiliate',
commission_type: 'percentage',
commission_rate: 0.15
)

PHP

$client = new \Affilync\AffilyncClient('af_live_...');

$campaign = $client->campaigns->create([
'name' => 'My Campaign',
'type' => 'affiliate',
'commission_type' => 'percentage',
'commission_rate' => 0.15,
]);

Go

client := affilync.New("af_live_...")

campaign, err := client.Campaigns.Create(ctx, &affilync.CampaignCreateParams{
Name: "My Campaign",
Type: affilync.CampaignTypeAffiliate,
CommissionType: affilync.CommissionTypePercentage,
CommissionRate: affilync.Float64(0.15),
})

C# / .NET

var client = new AffilyncClient("af_live_...");

var campaign = await client.Campaigns.CreateAsync(new CampaignCreateOptions {
Name = "My Campaign",
Type = CampaignType.Affiliate,
CommissionType = CommissionType.Percentage,
CommissionRate = 0.15m,
});

What every SDK gives you

  • Typed responses — full type definitions for every API resource.
  • Auto-pagination — iterate through all pages without managing cursors.
  • Automatic retries — exponential backoff on 429 and 5xx responses.
  • Webhook verification — built-in HMAC-SHA256 signature validation.
  • Typed errors — a distinct exception per HTTP status code.
  • Idempotency — auto-generated idempotency keys for POST/DELETE requests.
  • Rate-limit info — surfaced on every response.

API resources

Each SDK exposes the same resources and methods:

ResourceMethods
campaignscreate, retrieve, update, list, delete, pause, resume
linkscreate, retrieve, update, list, delete, batch_create
clickslist, retrieve
conversionscreate, retrieve, list, verify
analyticsdashboard, metrics, reports, export, realtime
paymentscreate, retrieve, list, refund
payoutsrequest, retrieve, list
subscriptionscreate, retrieve, update, cancel, upgrade
marketplacesearch, campaigns, brands, apply
aichat, generate_script, generate_image, voiceover
call_trackingnumbers.list, numbers.purchase, calls.list, analytics
mediaupload, list, retrieve, delete, create_folder
webhooksconstruct_event

Authentication

All SDKs use API key authentication:

  • Production keys start with af_live_
  • Test / sandbox keys start with af_test_

Create and manage keys at app.affilync.com/settings/api. For the full auth flow (including JWT sessions and token refresh) see Authentication.

Webhook events

Verify the signature on every incoming webhook with your SDK's webhooks.construct_event helper, then handle the events you care about:

EventDescription
campaign.createdNew campaign created
campaign.updatedCampaign updated
campaign.completedCampaign ended
link.createdNew link created
link.clickedLink received a click
conversion.createdNew conversion tracked
conversion.approvedConversion approved
conversion.rejectedConversion rejected
payout.requestedPayout requested
payout.completedPayout sent
payout.failedPayout failed
subscription.createdNew subscription
subscription.cancelledSubscription cancelled
call.completedCall finished
call.qualifiedCall qualified for payout

See the full Webhooks reference for payload shapes and signature verification details.

Next steps