🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

affitor-node

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

affitor-node

Affitor server-side SDK — typed trackLead()/trackSale() over the Affitor conversion API (Bearer). Provider-agnostic.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

affitor-node

Affitor server-side SDK — typed trackLead() / trackSale() over the Affitor conversion API. Provider-agnostic: works with Stripe, Polar, Lemon Squeezy, Paddle, or any payment processor.

Install

npm i affitor-node

Usage

import { Affitor } from 'affitor-node';

const affitor = new Affitor({ apiKey: process.env.AFFITOR_API_KEY! });

// At signup — binds the customer to the affiliate click:
await affitor.trackLead({ customerExternalId: user.id, clickId });

// At purchase (e.g. inside your Polar / Lemon Squeezy / Stripe webhook handler):
await affitor.trackSale({
  customerExternalId: user.id,   // resolves attribution — no clickId needed once bound
  amount: 4999,                  // integer cents
  invoiceId: order.id,           // idempotency key
  saleType: 'subscription',
  isRecurring: true,
  subscriptionInterval: 'monthly',
});

Attribution model (Dub-style): bind the customer at lead time (customerExternalId ↔ clickId), then a sale only needs customerExternalId. No need to thread the click id through a Merchant-of-Record checkout.

Server-side only — the program API key is a secret; never ship it to a browser. For browser click/lead capture use affitor-sdk.

API

MethodEndpointAuth
trackLead({ customerExternalId, clickId, email? })POST /api/v1/track/leadBearer
trackSale({ customerExternalId, amount, invoiceId, currency?, saleType?, isRecurring?, subscriptionId?, subscriptionInterval? })POST /api/v1/track/saleBearer
trackClick({ affiliateUrl?, ... })POST /api/v1/track/clickpublic

Methods resolve to { ok, status, data, error } (they don't reject on HTTP/network errors). Programmer errors (missing apiKey, invalid amount/invoiceId) throw.

Options: new Affitor({ apiKey, apiUrl?, fetch? })apiUrl defaults to https://api.affitor.com; pass fetch for Node < 18 or testing.

Keywords

affiliate

FAQs

Package last updated on 25 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts