|
1 | 1 | # ShapeShift Affiliate Program |
2 | 2 |
|
3 | | -Earn revenue share on swaps executed through your integration. |
| 3 | +Earn revenue share on swaps executed through your integration — whether you embed the |
| 4 | +[Swap Widget](../packages/swap-widget/README.md) or call the |
| 5 | +[Public API](../packages/public-api/docs/introduction.md) directly. |
| 6 | + |
| 7 | +Attribution is driven by a **partner code**: a short identifier registered to an EVM wallet address. |
| 8 | +Pass it to the widget or the API, and ShapeShift attributes each swap to your affiliate account and |
| 9 | +applies your configured fee automatically. |
4 | 10 |
|
5 | 11 | ## Quick Start |
6 | 12 |
|
7 | | -### 1. Using the Swap Widget |
| 13 | +### 1. Get a partner code |
| 14 | + |
| 15 | +Register at the [Affiliate Dashboard](https://dashboard.affiliate.shapeshift.com/): connect your wallet, sign |
| 16 | +in (a wallet signature — no gas), then choose your partner code and fee. The code is mapped to your |
| 17 | +wallet, and you'll use it everywhere below. |
| 18 | + |
| 19 | +### 2. Using the Swap Widget |
| 20 | + |
| 21 | +Pass your `partnerCode` prop. The widget renders once Reown AppKit is initialized: either pass |
| 22 | +`walletConnectProjectId` and the widget initializes AppKit for you (shown below), or initialize AppKit |
| 23 | +yourself in the host app and the widget reads the shared instance — see the |
| 24 | +[widget README](../packages/swap-widget/README.md). |
8 | 25 |
|
9 | 26 | ```tsx |
10 | 27 | import { SwapWidget } from '@shapeshiftoss/swap-widget' |
11 | 28 |
|
12 | 29 | <SwapWidget |
13 | | - affiliateAddress="0xYourWalletAddress" |
14 | | - // Optional: use a partner code instead |
15 | | - partnerCode="yourcode" |
16 | | - // Optional: override BPS (if registered) |
17 | | - affiliateBps="100" |
| 30 | + walletConnectProjectId="your-walletconnect-project-id" |
| 31 | + partnerCode="your-partner-code" |
18 | 32 | /> |
19 | 33 | ``` |
20 | 34 |
|
21 | | -### 2. Using the Public API |
22 | | - |
23 | | -Include these headers in your API requests: |
| 35 | +### 3. Using the Public API |
24 | 36 |
|
25 | | -```bash |
26 | | -curl https://api.shapeshift.com/v1/swap/rates \ |
27 | | - -H "X-Affiliate-Address: 0xYourWalletAddress" \ |
28 | | - -H "Content-Type: application/json" \ |
29 | | - -d '{"sellAssetId": "...", "buyAssetId": "...", "sellAmountCryptoBaseUnit": "..."}' |
30 | | -``` |
31 | | - |
32 | | -Or use a partner code: |
| 37 | +Send the `X-Partner-Code` header on the swap endpoints (`/v1/swap/rates`, `/v1/swap/quote`, |
| 38 | +`/v1/swap/status`). The API attributes the swap to your affiliate account and applies your configured fee. |
33 | 39 |
|
34 | 40 | ```bash |
35 | | -curl https://api.shapeshift.com/v1/swap/rates \ |
36 | | - -H "X-Partner-Code: yourcode" \ |
37 | | - -H "Content-Type: application/json" \ |
38 | | - -d '...' |
| 41 | +curl "https://api.shapeshift.com/v1/swap/rates?sellAssetId=eip155:1/slip44:60&buyAssetId=eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&sellAmountCryptoBaseUnit=1000000000000000000" \ |
| 42 | + -H "X-Partner-Code: your-partner-code" |
39 | 43 | ``` |
40 | 44 |
|
41 | | -## Headers |
42 | | - |
43 | | -| Header | Description | |
44 | | -|--------|-------------| |
45 | | -| `X-Affiliate-Address` | Your EVM wallet address (0x...) | |
46 | | -| `X-Partner-Code` | Your partner code (if registered) | |
47 | | -| `X-Affiliate-Bps` | Override BPS (optional, 0-1000) | |
48 | | - |
49 | | -## Registering as an Affiliate |
| 45 | +## The `X-Partner-Code` header |
50 | 46 |
|
51 | | -1. Go to the [Affiliate Dashboard](https://affiliate.shapeshift.com) |
52 | | -2. Connect your wallet |
53 | | -3. Your address is automatically registered with default BPS |
54 | | -4. Optionally claim a partner code |
| 47 | +| Header | Description | |
| 48 | +| ---------------- | ------------------------------------------------------------------------ | |
| 49 | +| `X-Partner-Code` | Your registered partner code. Attributes the swap to your affiliate account and applies your fee. | |
55 | 50 |
|
56 | | -### Partner Codes |
| 51 | +The partner code is the attribution mechanism: it maps to the affiliate parameters (payout address |
| 52 | +and fee) configured for your account, so there's no separate address or bps header to send. Requests |
| 53 | +without a partner code still succeed, but the swap is unattributed and uses the default fee. |
57 | 54 |
|
58 | | -Partner codes are short identifiers (3-32 alphanumeric characters) that map to your wallet. Benefits: |
| 55 | +## Fees |
59 | 56 |
|
60 | | -- Easier to share than a wallet address |
61 | | -- Can be used in place of `X-Affiliate-Address` |
62 | | -- One code per affiliate |
| 57 | +Fees are expressed in **basis points (bps)** — 1 bps = 0.01%, so 60 bps = 0.6%. The fee that applies |
| 58 | +to swaps attributed to your partner code is configured at registration; swaps with no partner code |
| 59 | +use ShapeShift's default fee. |
63 | 60 |
|
64 | | -Reserved codes: `shapeshift`, `ss`, `admin`, `api`, `test`, `demo` |
| 61 | +The API surfaces the fee breakdown for each rate/quote via the `affiliateBps` (total) and |
| 62 | +`shapeshiftBps` fields, plus `partnerBps` when the swap is attributed to a partner code — these |
| 63 | +reflect the fee that will actually be applied, so read them per quote rather than assuming a fixed rate. |
65 | 64 |
|
66 | | -## Fee Structure |
| 65 | +## Revenue Attribution & Reporting |
67 | 66 |
|
68 | | -| BPS | Percentage | Description | |
69 | | -|-----|------------|-------------| |
70 | | -| 10 | 0.1% | Minimum (API base) | |
71 | | -| 60 | 0.6% | Default | |
72 | | -| 100 | 1.0% | Example custom | |
73 | | - |
74 | | -- **BPS** = Basis Points (1 BPS = 0.01%) |
75 | | -- Fees are taken from the sell amount |
76 | | -- Related asset swaps (e.g., ETH → WETH) have 0% fee |
77 | | - |
78 | | -## Revenue Attribution |
79 | | - |
80 | | -Every swap executed through your integration is tracked: |
81 | | - |
82 | | -- Your affiliate address is recorded |
83 | | -- Volume and fees are calculated |
84 | | -- Stats available in the affiliate dashboard |
85 | | - |
86 | | -### Viewing Your Stats |
| 67 | +Every swap carrying your partner code is attributed to you. Review your activity in the dashboard, or |
| 68 | +query the API by partner code: |
87 | 69 |
|
88 | 70 | ```bash |
89 | | -# Get your stats |
90 | | -curl "https://api.shapeshift.com/v1/affiliate/stats?address=0xYour..." |
| 71 | +# Aggregate stats (optional startDate / endDate) |
| 72 | +curl "https://api.shapeshift.com/v1/affiliate/stats?partnerCode=your-partner-code" |
91 | 73 |
|
92 | | -# Response |
| 74 | +# Example response |
93 | 75 | { |
94 | 76 | "totalSwaps": 1234, |
95 | 77 | "totalVolumeUsd": "1234567.89", |
96 | 78 | "totalFeesEarnedUsd": "7407.41" |
97 | 79 | } |
98 | 80 | ``` |
99 | 81 |
|
100 | | -## API Endpoints |
101 | | - |
102 | | -### Public Endpoints |
103 | | - |
104 | | -| Method | Endpoint | Description | |
105 | | -|--------|----------|-------------| |
106 | | -| GET | `/v1/affiliate/stats?address=...` | Get swap stats | |
107 | | -| GET | `/v1/partner/:code` | Resolve partner code | |
| 82 | +```bash |
| 83 | +# Paginated swap history (optional startDate / endDate / limit / cursor) |
| 84 | +curl "https://api.shapeshift.com/v1/affiliate/swaps?partnerCode=your-partner-code" |
| 85 | +``` |
108 | 86 |
|
109 | | -### Authenticated Endpoints (requires wallet signature) |
| 87 | +## Affiliate API Endpoints |
110 | 88 |
|
111 | | -| Method | Endpoint | Description | |
112 | | -|--------|----------|-------------| |
113 | | -| POST | `/v1/affiliate` | Register as affiliate | |
114 | | -| PATCH | `/v1/affiliate/:address` | Update settings | |
115 | | -| POST | `/v1/affiliate/claim-code` | Claim partner code | |
| 89 | +| Method | Endpoint | Auth | Description | |
| 90 | +| ------ | ----------------------------------------- | --------------- | ---------------------------------------- | |
| 91 | +| GET | `/v1/affiliate/stats?partnerCode=...` | none | Aggregate swap stats for a partner code | |
| 92 | +| GET | `/v1/affiliate/swaps?partnerCode=...` | none | Paginated swap history for a partner code | |
| 93 | +| GET | `/v1/partner/{code}` | none | Resolve a partner code to its attribution details (address, bps split) | |
| 94 | +| GET | `/v1/affiliate/{address}` | none | Look up an affiliate by wallet address | |
| 95 | +| POST | `/v1/affiliate` | wallet (SIWE) | Register as an affiliate | |
| 96 | +| PATCH | `/v1/affiliate/{address}` | wallet (SIWE) | Update affiliate settings | |
116 | 97 |
|
117 | | -## Support |
| 98 | +Wallet-authenticated endpoints use Sign-In With Ethereum (`POST /v1/auth/siwe/nonce` → |
| 99 | +`POST /v1/auth/siwe/verify`). Most partners never call these directly — the |
| 100 | +[Affiliate Dashboard](https://dashboard.affiliate.shapeshift.com/) handles registration for you. |
118 | 101 |
|
119 | | -- **Dashboard**: https://affiliate.shapeshift.com |
120 | | -- **Discord**: https://discord.gg/shapeshift |
121 | | -- **Email**: affiliates@shapeshift.com |
| 102 | +See the full request/response schemas in the [Public API reference](https://api.shapeshift.com/docs). |
0 commit comments