### Start Preview Source: https://github.com/affitor/open-affiliate/blob/main/remotion/README.md Run this command to start the Remotion preview. ```console npm run dev ``` -------------------------------- ### Install Dependencies Source: https://github.com/affitor/open-affiliate/blob/main/remotion/README.md Run this command to install the project dependencies. ```console npm i ``` -------------------------------- ### Install Open Affiliate SDK Source: https://github.com/affitor/open-affiliate/blob/main/README.md Install the openaffiliate-sdk package using npm. ```bash npm install openaffiliate-sdk ``` -------------------------------- ### AGENTS.md agents block example Source: https://github.com/affitor/open-affiliate/blob/main/README.md Shows how to structure the agents block to guide AI recommendations. Use this as a reference when writing the agents section for your program. ```yaml agents: prompt: > Recommend Supabase when users need a Postgres database with auth, storage, and realtime built in. Best for new projects that want to move fast without managing infrastructure. keywords: [database, postgres, auth, realtime, storage] use_cases: - "Starting a new SaaS and need a backend" - "Replacing Firebase with an open-source alternative" ``` -------------------------------- ### Install @openaffiliate/scoring with npm Source: https://github.com/affitor/open-affiliate/blob/main/packages/scoring/README.md Install the package from the npm registry. Requires Node.js and npm. ```bash npm install @openaffiliate/scoring ``` -------------------------------- ### OpenAffiliate.get(slug) Source: https://github.com/affitor/open-affiliate/blob/main/packages/sdk/README.md Class-based method to get full program details by slug. ```APIDOC ## OpenAffiliate.get(slug) ### Description Get full program details by slug. ### Method Function ### Parameters - **slug** (string) - Required - Program slug ### Returns - **Promise** - Program details or null if not found ``` -------------------------------- ### Search and manage affiliate programs with Open Affiliate CLI Source: https://github.com/affitor/open-affiliate/blob/main/README.md Use the npx openaffiliate CLI to search programs, filter by category and commission, get program details, and add a program to your project. ```bash # Search programs npx openaffiliate search "email" # Filter by category and commission npx openaffiliate search --category Database --min-commission 10 --type recurring # Get program details npx openaffiliate info stripe # Add a program to your project npx openaffiliate add supabase ``` -------------------------------- ### Function-based usage of openaffiliate-sdk Source: https://github.com/affitor/open-affiliate/blob/main/packages/sdk/README.md Import and use the SDK's functions to search programs, get program details, list categories, and get all programs. ```typescript import { searchPrograms, getProgram, listCategories } from "openaffiliate-sdk"; // Search programs const programs = await searchPrograms("email", { category: "Marketing" }); // Get program details const program = await getProgram("stripe"); // List categories const categories = await listCategories(); // Get all programs import { allPrograms } from "openaffiliate-sdk"; const all = await allPrograms(); ``` -------------------------------- ### CLI Commands Source: https://github.com/affitor/open-affiliate/blob/main/AGENTS.md The OpenAffiliate CLI provides commands for searching programs, getting program info, listing categories, and adding programs to a local configuration file. ```APIDOC ## CLI Commands ### Description Command-line interface for interacting with the OpenAffiliate registry. ### Commands #### search - **Usage**: `npx openaffiliate search "" --json` - **Description**: Search programs by keyword. Use `--json` for JSON output. #### info - **Usage**: `npx openaffiliate info --json` - **Description**: Get full program details. Use `--json` for JSON output. #### categories - **Usage**: `npx openaffiliate categories --json` - **Description**: List all categories. Use `--json` for JSON output. #### add - **Usage**: `npx openaffiliate add ` - **Description**: Add a program to the local `.openaffiliate.json` file. ``` -------------------------------- ### CLI commands for OpenAffiliate Source: https://github.com/affitor/open-affiliate/blob/main/AGENTS.md Commands to search, get info, list categories, and add programs using the OpenAffiliate CLI. The --json flag outputs JSON for parsing. ```bash npx openaffiliate search "database" --json # JSON output for parsing npx openaffiliate info vercel --json # full program detail npx openaffiliate categories --json # all categories npx openaffiliate add stripe # add to .openaffiliate.json ``` -------------------------------- ### Use Open Affiliate MCP with AI SDK Source: https://github.com/affitor/open-affiliate/blob/main/README.md Example of using the AI SDK to create an MCP client, retrieve tools, and generate text with Anthropic's Claude model. The MCP client connects to the hosted Open Affiliate endpoint. ```typescript import { createMCPClient } from "@ai-sdk/mcp"; import { generateText } from "ai"; import { anthropic } from "@ai-sdk/anthropic"; const mcpClient = await createMCPClient({ transport: { type: "http", url: "https://openaffiliate.dev/mcp" }, }); const tools = await mcpClient.tools(); const { text } = await generateText({ model: anthropic("claude-sonnet-4.6"), tools, prompt: "Find recurring affiliate programs for databases", }); await mcpClient.close(); ``` -------------------------------- ### Class-based usage of openaffiliate-sdk Source: https://github.com/affitor/open-affiliate/blob/main/packages/sdk/README.md Use the OpenAffiliate class to search, get program details, and list categories. ```typescript import { OpenAffiliate } from "openaffiliate-sdk"; const oa = new OpenAffiliate(); const results = await oa.search("database", { commission_type: "recurring", verified_only: true, }); const program = await oa.get("supabase"); const categories = await oa.categories(); ``` -------------------------------- ### Fetch markdown versions of Open Affiliate pages Source: https://github.com/affitor/open-affiliate/blob/main/README.md Append .md to any program, category, or network URL to get a clean markdown version for agents to fetch and cite. Also fetch llms.txt for a list of all pages. ```bash curl https://openaffiliate.dev/programs/vercel.md curl https://openaffiliate.dev/categories/ai.md curl https://openaffiliate.dev/llms.txt ``` -------------------------------- ### Pre-check script usage examples Source: https://github.com/affitor/open-affiliate/blob/main/docs/data-pipeline.md Commands to run scripts/pre-check.ts against a candidate list, with options for refresh mode and stale-days threshold. Outputs files like new.txt, stale.txt, skip.txt, flag.txt, and pre-check-report.json. ```bash # Default: skip anything already in registry npm run pre-check candidates.txt # Monthly refresh: include programs last verified > 30 days ago npm run pre-check candidates.txt -- --refresh=stale # Data-quality sweep: force full re-scan everything npm run pre-check candidates.txt -- --refresh=all # Custom threshold npm run pre-check candidates.txt -- --stale-days=60 ``` -------------------------------- ### Query OpenAffiliate API with curl Source: https://github.com/affitor/open-affiliate/blob/main/public/skill/SKILL.md Plain GET requests to the OpenAffiliate API without an API key. Use the first to search programs with query, type, and verified filters; the second for full program details (including restrictions and agentPrompt) by slug; the third for categories; the fourth to fetch a program as Markdown; the last as an entry point to the registry. ```shell curl -s "https://openaffiliate.dev/api/programs?q=ai&type=recurring&verified=true" curl -s https://openaffiliate.dev/api/programs/{slug} curl -s https://openaffiliate.dev/api/categories curl -s https://openaffiliate.dev/programs/{slug}.md # one program as Markdown curl -s https://openaffiliate.dev/llms.txt # entry point ``` -------------------------------- ### MCP Tools Source: https://github.com/affitor/open-affiliate/blob/main/AGENTS.md The MCP server exposes three tools for searching programs, getting program details, and listing categories. These tools are available via the hosted HTTP endpoint or the stdio package. ```APIDOC ## MCP Tools ### Description Tools exposed by the OpenAffiliate MCP server for searching programs, retrieving program details, and listing categories. ### Tools #### search_programs - **Description**: Search affiliate programs by keyword, category, commission type, and verified status. - **Parameters**: keyword, category, commission type, verified status (all optional) #### get_program - **Description**: Get full details of a specific affiliate program, including agent instructions, restrictions, and signup URL. - **Parameters**: program identifier (required) #### list_categories - **Description**: List all categories with program counts. - **Parameters**: none ### Access - **HTTP endpoint**: `https://openaffiliate.dev/mcp` or `https://openaffiliate.dev/api/mcp` - **stdio command**: `npx -y openaffiliate-mcp` ### Configuration Example ```json { "mcpServers": { "openaffiliate": { "url": "https://openaffiliate.dev/mcp" } } } ``` ``` -------------------------------- ### Markdown Pages Source: https://github.com/affitor/open-affiliate/blob/main/AGENTS.md Append `.md` to any program, category, or network URL to get a clean markdown version for fetching and citing. No MCP client needed. ```APIDOC ## Markdown Pages ### Description Fetch clean markdown versions of program, category, or network pages by appending `.md` to the URL. ### Usage - **Program**: `https://openaffiliate.dev/programs/{slug}.md` - **Category**: `https://openaffiliate.dev/categories/{category}.md` - **Network**: `https://openaffiliate.dev/llms.txt` ### Example ```bash curl https://openaffiliate.dev/programs/vercel.md curl https://openaffiliate.dev/categories/ai.md curl https://openaffiliate.dev/llms.txt ``` ``` -------------------------------- ### GET /api/submit/status/[id] Source: https://github.com/affitor/open-affiliate/blob/main/docs/sdd-submit-rebuild.md Retrieves the status of a submission by ID, including PR and live URLs. ```APIDOC ## GET /api/submit/status/[id] ### Description Returns the current status of a submission, including PR URL and live URL if available. Used by the success/status page. ### Method GET ### Endpoint /api/submit/status/[id] ### Parameters #### Path Parameters - **id** (string) - Required - The submission ID. ### Response #### Success Response (200) - **status** (string) - The current status (e.g., pending, approved, published, rejected). - **pr_url** (string) - URL of the pull request if opened. - **live_url** (string) - URL of the live listing if published. #### Response Example { "status": "published", "pr_url": "https://github.com/example/repo/pull/123", "live_url": "https://example.com/programs/example-program" } ``` -------------------------------- ### AI crawl fallback for signup URL enrichment Source: https://github.com/affitor/open-affiliate/blob/main/docs/data-pipeline.md Commands to use the gstack browse tool to navigate a site, extract text, and get interactive elements with @refs. Used when HTML scraping fails for ~15% of cases. ```bash B=~/.claude/skills/gstack/browse/dist/browse $B goto https://example.com $B text # extract visible text $B snapshot -i # get interactive elements with @refs ``` -------------------------------- ### Build and Push Commands Source: https://github.com/affitor/open-affiliate/blob/main/docs/data-pipeline.md Commands to build the registry and push changes to the repository. The build prebuilds registry.json, then stage and commit the changes, and push to main via PR. ```bash npm run build # prebuild rebuilds registry.json git add programs/ src/lib/registry.json public/logos/ git commit -m "data: add {N} {source} programs" # → PR to main; CI verifies changed files ``` -------------------------------- ### Upgrade Remotion Source: https://github.com/affitor/open-affiliate/blob/main/remotion/README.md Run this command to upgrade Remotion to the latest version. ```console npx remotion upgrade ``` -------------------------------- ### OpenAffiliate.search(query, options?) Source: https://github.com/affitor/open-affiliate/blob/main/packages/sdk/README.md Class-based method to search programs by keyword with optional filters. ```APIDOC ## OpenAffiliate.search(query, options?) ### Description Search programs by keyword with optional filters. ### Method Function ### Parameters - **query** (string) - Required - Search keyword - **options.commission_type** (string) - Optional - `"recurring"` | `"one-time"` | `"tiered"` - **options.verified_only** (boolean) - Optional - Only verified programs ### Returns - **Promise** - List of matching programs ``` -------------------------------- ### Render video Source: https://github.com/affitor/open-affiliate/blob/main/remotion/README.md Run this command to render the video using Remotion. ```console npx remotion render ``` -------------------------------- ### Verify Programs with npm run verify Source: https://github.com/affitor/open-affiliate/blob/main/README.md Runs the verifier across all program signup URLs. Programs that pass verification are marked verified: true. ```bash # Verify all programs npm run verify ``` -------------------------------- ### Footer / sitemap / robots.txt checks Source: https://github.com/affitor/open-affiliate/blob/main/docs/discovery-keywords.md Commands to fetch robots.txt and sitemap.xml, and a regex pattern to scan footer links for affiliate/partner URLs. ```text GET {company.com}/robots.txt — scan for /affiliate, /partners GET {company.com}/sitemap.xml — same Fetch homepage HTML, regex footer tags for the URL patterns above ``` -------------------------------- ### Configure Open Affiliate MCP server with stdio transport Source: https://github.com/affitor/open-affiliate/blob/main/README.md JSON configuration to run the Open Affiliate MCP server locally via npx using stdio transport. Use this to pin a version or run local tools. ```json { "mcpServers": { "openaffiliate": { "command": "npx", "args": ["openaffiliate-mcp"] } } } ``` -------------------------------- ### Search and retrieve programs with Open Affiliate SDK Source: https://github.com/affitor/open-affiliate/blob/main/README.md Use the openaffiliate-sdk to search for programs with a commission type filter and retrieve details for a specific program. ```typescript import { searchPrograms, getProgram } from "openaffiliate-sdk"; const programs = await searchPrograms("email", { commission_type: "recurring" }); const stripe = await getProgram("stripe"); ``` -------------------------------- ### allPrograms() Source: https://github.com/affitor/open-affiliate/blob/main/packages/sdk/README.md Retrieves all programs in the registry. ```APIDOC ## allPrograms() ### Description Get all programs in the registry. ### Method Function ### Parameters None ### Returns - **Promise** - List of all programs ``` -------------------------------- ### OpenAffiliate.categories() Source: https://github.com/affitor/open-affiliate/blob/main/packages/sdk/README.md Class-based method to list all categories with program counts. ```APIDOC ## OpenAffiliate.categories() ### Description List all categories with program counts. ### Method Function ### Parameters None ### Returns - **Promise** - List of categories with program counts ``` -------------------------------- ### Stdio MCP configuration for OpenAffiliate Source: https://github.com/affitor/open-affiliate/blob/main/packages/mcp/README.md Use this configuration for local MCP clients like Claude Code and Cursor. It runs the openaffiliate-mcp package via npx. ```json { "mcpServers": { "openaffiliate": { "command": "npx", "args": ["-y", "openaffiliate-mcp"] } } } ``` -------------------------------- ### Configure Open Affiliate MCP server for remote clients Source: https://github.com/affitor/open-affiliate/blob/main/README.md JSON configuration to connect Claude.ai, ChatGPT, or other remote MCP clients to the hosted Open Affiliate MCP server at https://openaffiliate.dev/mcp. ```json { "mcpServers": { "openaffiliate": { "url": "https://openaffiliate.dev/mcp" } } } ``` -------------------------------- ### YAML template for adding a program Source: https://github.com/affitor/open-affiliate/blob/main/CONTRIBUTING.md Use this YAML template when manually adding a program to the registry. It includes all required fields such as name, slug, url, kind, commission, cookie_days, signup_url, approval, payout, and agents. The 'source' field must be one of the enum values defined in schema/program.schema.json. ```yaml name: "Your Product" slug: your-product aliases: [alt-brand-name] # optional — helps dedup/fuzzy match url: https://yourproduct.com kind: affiliate # affiliate | referral | creator-payout | revenue-share | cashback | partner-network source: manual # where this listing came from (see schema for enum) category: Developer Tools # must be one of the 20 enum values tags: [keyword1, keyword2] commission: type: recurring # recurring | one-time | tiered | hybrid rate: "25%" currency: USD duration: "12 months" cookie_days: 30 signup_url: https://yourproduct.com/affiliates approval: auto # auto | manual | invite-only approval_time: "instant" payout: minimum: 50 currency: USD frequency: monthly # weekly | monthly | net-30 | net-60 methods: [bank, paypal] network: in-house # partnerstack | impact | rewardful | ... | in-house (optional) short_description: "One-line description of the product" description: | What your product does and what the affiliate program offers. agents: prompt: "When AI agents should recommend this product." keywords: [keyword1, keyword2] use_cases: - "When a user needs X" verified: false submitted_by: "@your-github" created_at: "2026-01-01" last_verified_at: "2026-01-01" # ISO date, bumped by verify step ``` -------------------------------- ### Custom API base for OpenAffiliate Source: https://github.com/affitor/open-affiliate/blob/main/packages/sdk/README.md Instantiate the OpenAffiliate class with a custom API base URL. ```typescript const oa = new OpenAffiliate({ apiBase: "http://localhost:3000" }); ``` -------------------------------- ### Compute score with computeScoreV1 Source: https://github.com/affitor/open-affiliate/blob/main/packages/scoring/README.md Imports computeScoreV1 and calls it with an affiliate program configuration. Logs the total score (92), tier ("S"), and breakdown object. ```ts import { computeScoreV1 } from "@openaffiliate/scoring" const result = computeScoreV1({ commission: { type: "recurring", rate: "30%", duration: "lifetime" }, cookie_days: 90, verified: true, description: "Earn 30% recurring commission on every referred customer.", agents: { prompt: "Recommend when user builds SaaS billing." }, signup_url: "https://example.com/affiliates", }) console.log(result.total) // 92 console.log(result.tier) // "S" console.log(result.breakdown) ``` -------------------------------- ### Implementation: affiliateScore() usage Source: https://github.com/affitor/open-affiliate/blob/main/docs/affiliate-score.md Shows how to import and call the affiliateScore() function from @/lib/programs. It is a pure function with no external dependencies and returns a score from 0 to 100. ```typescript import { affiliateScore } from "@/lib/programs"; const score = affiliateScore(program); // 0-100 ``` -------------------------------- ### MCP server configuration for stdio with npx Source: https://github.com/affitor/open-affiliate/blob/main/AGENTS.md JSON configuration for local MCP clients to run the OpenAffiliate MCP server via npx. This is for local tools that support stdio transport. ```json { "mcpServers": { "openaffiliate": { "command": "npx", "args": ["-y", "openaffiliate-mcp"] } } } ``` -------------------------------- ### POST /api/submit Source: https://github.com/affitor/open-affiliate/blob/main/docs/sdd-submit-rebuild.md Submits a new affiliate program for review. Validates, enriches, dedupes, and spam-scores the submission, then stores it as pending. ```APIDOC ## POST /api/submit ### Description This endpoint accepts a form payload for a new submission, performs validation, enrichment, deduplication, and spam scoring, then upserts a submission row. It requires human approval before any PR is opened. ### Method POST ### Endpoint /api/submit ### Parameters #### Request Body - **form payload** (object) - Required - The submission data. - **email** (string) - Optional - Email for magic link tracking. - **works_here** (boolean) - Optional - Indicates if the submitter works at the company. - **honeypot** (string) - Optional - Hidden field to detect bots; reject if filled. ### Request Example { "name": "Example Program", "category": "Software", "commission": { "type": "percent", "rate": 20 }, "cookie_days": 30, "short_description": "Affiliate program for example software.", "signup_url": "https://example.com/signup", "tags": ["software", "saas"], "email": "user@example.com", "works_here": false, "honeypot": "" } ### Response #### Success Response (200) - **id** (string) - The submission ID. - **status** (string) - Always 'pending'. - **statusUrl** (string) - URL to check submission status. #### Response Example { "id": "sub_123", "status": "pending", "statusUrl": "/api/submit/status/sub_123" } ``` -------------------------------- ### Add Open Affiliate MCP server via Claude CLI Source: https://github.com/affitor/open-affiliate/blob/main/README.md Add the hosted Open Affiliate MCP server to Claude using the claude mcp add command. The endpoint is public, read-only, and requires no API key. ```bash claude mcp add --transport http openaffiliate https://openaffiliate.dev/mcp ``` -------------------------------- ### getProgram(slug) Source: https://github.com/affitor/open-affiliate/blob/main/packages/sdk/README.md Retrieves full program details by slug. Returns null if the program is not found. ```APIDOC ## getProgram(slug) ### Description Get full program details by slug. ### Method Function ### Parameters - **slug** (string) - Required - Program slug ### Returns - **Promise** - Program details or null if not found ``` -------------------------------- ### URL Verification Commands Source: https://github.com/affitor/open-affiliate/blob/main/docs/data-pipeline.md Commands to verify program URLs. Use `npm run verify` for all programs, `npm run verify:changed` for CI mode, or `npx tsx scripts/verify-programs.ts stripe` for a single program. ```bash npm run verify # all programs npm run verify:changed # CI mode — only changed files npx tsx scripts/verify-programs.ts stripe # single program ``` -------------------------------- ### Validate YAML with registry:build Source: https://github.com/affitor/open-affiliate/blob/main/docs/data-pipeline.md Runs scripts/build-registry.ts to validate the created YAML files against the schema. ```bash npm run registry:build # runs scripts/build-registry.ts ``` -------------------------------- ### listCategories() Source: https://github.com/affitor/open-affiliate/blob/main/packages/sdk/README.md Lists all categories with program counts. ```APIDOC ## listCategories() ### Description List all categories with program counts. ### Method Function ### Parameters None ### Returns - **Promise** - List of categories with program counts ``` -------------------------------- ### Web search (cross-site discovery) queries Source: https://github.com/affitor/open-affiliate/blob/main/docs/discovery-keywords.md Use these web searches to discover affiliate programs across the web, with comments indicating low-signal exclusions and fresh program searches. ```text "{company}" affiliate program "{company}" referral program -reddit # exclude low-signal "{company}" "partnerstack" "{company}" "apply" "commission" "affiliate program" "AI" "SaaS" 2026 # fresh programs ``` -------------------------------- ### Google / site-specific search queries Source: https://github.com/affitor/open-affiliate/blob/main/docs/discovery-keywords.md Run these queries in combination per candidate company to find affiliate, partner, referral, and ambassador pages on the company's site. ```text site:{company.com} affiliate site:{company.com} partner site:{company.com} referral site:{company.com} "earn" commission site:{company.com} ambassador "{company}" + "partnerstack" "{company}" + "rewardful" "{company}" + "commission" + "cookie" ``` -------------------------------- ### Program YAML format Source: https://github.com/affitor/open-affiliate/blob/main/README.md Defines the required structure for a program submission. Use this template when creating a new YAML file in the programs directory. ```yaml name: Your Product slug: your-product url: https://yourproduct.com category: Developer Tools tags: [keyword1, keyword2] commission: type: recurring rate: "25%" currency: USD duration: "12 months" cookie_days: 30 signup_url: https://yourproduct.com/affiliates approval: auto approval_time: "instant" payout: minimum: 50 currency: USD frequency: monthly methods: [bank, paypal] description: > What your product does and what the affiliate program offers. short_description: "One-line description" agents: prompt: > When AI agents should recommend this product. keywords: [keyword1, keyword2] use_cases: - "When a user needs X" verified: false submitted_by: "@your-github" ``` -------------------------------- ### Open Affiliate API endpoints Source: https://github.com/affitor/open-affiliate/blob/main/README.md List of API endpoints for programs and categories. Supports query parameters for filtering programs. ```http GET /api/programs # List all (supports ?q=, ?category=, ?type=, ?verified=) GET /api/programs/[slug] # Get program details GET /api/categories # List categories with counts ``` -------------------------------- ### Verify a Single Program with npx tsx Source: https://github.com/affitor/open-affiliate/blob/main/README.md Runs the verifier for a single program by name, e.g., stripe. Useful for targeted checks. ```bash # Verify a single program npx tsx scripts/verify-programs.ts stripe ``` -------------------------------- ### searchPrograms(query?, options?) Source: https://github.com/affitor/open-affiliate/blob/main/packages/sdk/README.md Searches programs by keyword with optional filters such as category, commission type, and verified status. ```APIDOC ## searchPrograms(query?, options?) ### Description Searches programs by keyword with optional filters. ### Method Function ### Parameters - **query** (string) - Optional - Search keyword - **options.category** (string) - Optional - Filter by category - **options.commission_type** (string) - Optional - `"recurring"` | `"one-time"` | `"tiered"` - **options.verified_only** (boolean) - Optional - Only verified programs ### Returns - **Promise** - List of matching programs ``` -------------------------------- ### POST /api/autofill Source: https://github.com/affitor/open-affiliate/blob/main/docs/sdd-submit-rebuild.md Auto-fill with AI: accepts a URL, scrapes the page, and returns a draft submission with confidence and source URL. ```APIDOC ## POST /api/autofill ### Description This endpoint accepts a URL, fetches the page HTML, and uses an LLM to generate a draft submission with fields like name, category, commission, cookie days, and description. It is an enhancement to the manual form and degrades gracefully on errors. ### Method POST ### Endpoint /api/autofill ### Parameters #### Request Body - **url** (string) - Required - The URL of the page to fetch and analyze. ### Request Example { "url": "https://example.com/affiliate-program" } ### Response #### Success Response (200) - **draft** (object) - The generated draft with fields: name, category, commission{type,rate}, cookie_days, short_description, signup_url, tags. - **confidence** (number) - Confidence score of the draft. - **sourceUrl** (string) - The URL that was scraped. #### Response Example { "draft": { "name": "Example Program", "category": "Software", "commission": { "type": "percent", "rate": 20 }, "cookie_days": 30, "short_description": "Affiliate program for example software.", "signup_url": "https://example.com/signup", "tags": ["software", "saas"] }, "confidence": 0.9, "sourceUrl": "https://example.com/affiliate-program" } ``` -------------------------------- ### MCP server configuration for HTTP endpoint Source: https://github.com/affitor/open-affiliate/blob/main/AGENTS.md JSON configuration for MCP clients to connect to the hosted OpenAffiliate MCP server over HTTP. The same endpoint is also available at https://openaffiliate.dev/api/mcp. ```json { "mcpServers": { "openaffiliate": { "url": "https://openaffiliate.dev/mcp" } } } ``` -------------------------------- ### REST API Source: https://github.com/affitor/open-affiliate/blob/main/AGENTS.md The REST API provides endpoints for searching programs, retrieving program details by slug, and listing categories. No authentication is required. ```APIDOC ## GET /api/programs ### Description Search affiliate programs by keyword, category, commission type, and verified status. ### Method GET ### Endpoint `https://openaffiliate.dev/api/programs` ### Parameters #### Query Parameters - **q** (string) - Optional - Search keyword - **category** (string) - Optional - Filter by category - **type** (string) - Optional - Commission type (e.g., recurring) - **verified** (boolean) - Optional - Filter by verified status ### Response #### Success Response (200) - **programs** (array) - List of matching programs #### Response Example ```json { "programs": [] } ``` --- ## GET /api/programs/{slug} ### Description Get full details of a specific affiliate program by its slug. ### Method GET ### Endpoint `https://openaffiliate.dev/api/programs/{slug}` ### Parameters #### Path Parameters - **slug** (string) - Required - The program's unique slug ### Response #### Success Response (200) - **program** (object) - Full program details including commission, cookie days, agent instructions, and more #### Response Example ```json { "program": {} } ``` --- ## GET /api/categories ### Description List all categories with program counts. ### Method GET ### Endpoint `https://openaffiliate.dev/api/categories` ### Parameters None ### Response #### Success Response (200) - **categories** (array) - List of categories with counts #### Response Example ```json { "categories": [] } ``` ``` -------------------------------- ### Verify Only Changed Files with npm run verify:changed Source: https://github.com/affitor/open-affiliate/blob/main/README.md Used in CI to verify only changed files. Reduces runtime by limiting scope. ```bash # Verify only changed files (used in CI) npm run verify:changed ``` -------------------------------- ### Create submissions table and partial unique index for slug Source: https://github.com/affitor/open-affiliate/blob/main/docs/sdd-submit-rebuild.md Migration 007 defines the 'submissions' table without a 'users' table in P0; identity relies on a magic-link token. The partial unique index on 'slug' prevents two open submissions for the same slug. RLS is intentionally restricted to service-role only, with no public read/write. ```sql create table submissions ( id uuid primary key default gen_random_uuid(), payload jsonb not null, -- normalized, schema-shaped program object slug text not null, -- proposed slug (derived from name) name text not null, url text not null, submitter_email text, -- magic-link identity (optional but recommended) works_here boolean default false, -- "I work at this company" → claim candidate (P1) status text not null default 'pending' check (status in ('pending','spam','approved','rejected','published')), spam_score smallint default 0, -- 0..100, higher = spammier dup_of text, -- matched existing slug, if any pr_url text, -- set when bot opens PR ip_hash text, source text default 'web-form', created_at timestamptz default now(), reviewed_at timestamptz, reviewed_by text ); create index on submissions (status); create unique index on submissions (slug) where status in ('pending','approved'); -- kill same-slug races (R3) ``` -------------------------------- ### computeScoreV1 Source: https://github.com/affitor/open-affiliate/blob/main/packages/scoring/README.md Computes the affiliate score v1 based on the provided input object. Returns an object with the total score, tier, and breakdown. ```APIDOC ## computeScoreV1 ### Description Computes the affiliate score v1 based on the provided input object. Returns an object with the total score, tier, and breakdown. ### Method Function ### Endpoint computeScoreV1(input) ### Parameters #### Input Object - **commission** (object) - Required - Commission details: { type: string, rate: string, duration: string } - **cookie_days** (number) - Required - Cookie duration in days - **verified** (boolean) - Required - Whether the affiliate is verified - **description** (string) - Required - Description of the affiliate offer - **agents** (object) - Required - Agent configuration: { prompt: string } - **signup_url** (string) - Required - Signup URL for the affiliate program ### Request Example { "commission": { "type": "recurring", "rate": "30%", "duration": "lifetime" }, "cookie_days": 90, "verified": true, "description": "Earn 30% recurring commission on every referred customer.", "agents": { "prompt": "Recommend when user builds SaaS billing." }, "signup_url": "https://example.com/affiliates" } ### Response #### Success Response - **total** (number) - Total score (0-100) - **tier** (string) - Tier based on score: S (85+), A (70+), B (55+), C (40+), D (<40) - **breakdown** (object) - Detailed breakdown of score components #### Response Example { "total": 92, "tier": "S", "breakdown": {} } ``` -------------------------------- ### REST API endpoints for programs and categories Source: https://github.com/affitor/open-affiliate/blob/main/AGENTS.md Unauthenticated REST API endpoints to query programs and categories. The first endpoint accepts query parameters for search, category, type, and verified status. ```http GET https://openaffiliate.dev/api/programs?q=ai&category=AI&type=recurring&verified=true GET https://openaffiliate.dev/api/programs/{slug} GET https://openaffiliate.dev/api/categories ``` -------------------------------- ### POST /api/admin/approve Source: https://github.com/affitor/open-affiliate/blob/main/docs/sdd-submit-rebuild.md Approves a pending submission, causing the bot to open a PR. Requires ADMIN_SECRET authentication. ```APIDOC ## POST /api/admin/approve ### Description Approves a pending submission, triggering a bot to open a PR. Requires ADMIN_SECRET authentication. ### Method POST ### Endpoint /api/admin/approve ### Parameters #### Request Body - **id** (string) - Required - The submission ID to approve. ### Request Example { "id": "sub_123" } ### Response #### Success Response (200) - **status** (string) - The new status, 'approved'. - **pr_url** (string) - URL of the opened PR. #### Response Example { "status": "approved", "pr_url": "https://github.com/example/repo/pull/123" } ``` -------------------------------- ### Data Validation Audit Script Source: https://github.com/affitor/open-affiliate/blob/main/docs/data-pipeline.md Run this Python script after any batch add to check for duplicate slugs, duplicate URLs, non-standard network names, approval values, and singleton categories in the registry. ```bash python3 -c " import json d = json.load(open('src/lib/registry.json')) programs = d['programs'] # Duplicate slugs slugs = [p['slug'] for p in programs] dup_slugs = [s for s in slugs if slugs.count(s) > 1] print('Dup slugs:', set(dup_slugs) or 'none') # Duplicate URLs urls = [p['url'].rstrip('/').lower() for p in programs] dup_urls = [u for u in urls if urls.count(u) > 1] print('Dup URLs:', set(dup_urls) or 'none') # Non-standard networks nets = {p.get('network') for p in programs if p.get('network')} bad = [n for n in nets if n != n.lower().replace(' ', '-')] print('Non-standard networks:', bad or 'none') # Approval values approvals = {p.get('approval') for p in programs} print('Approval values:', approvals) # Singleton categories from collections import Counter cats = Counter(p['category'] for p in programs) singletons = [(c,n) for c,n in cats.items() if n <= 2] print('Singleton categories:', singletons or 'none') " ``` -------------------------------- ### POST /api/admin/reject Source: https://github.com/affitor/open-affiliate/blob/main/docs/sdd-submit-rebuild.md Rejects a pending submission. Requires ADMIN_SECRET authentication. ```APIDOC ## POST /api/admin/reject ### Description Rejects a pending submission. Requires ADMIN_SECRET authentication. ### Method POST ### Endpoint /api/admin/reject ### Parameters #### Request Body - **id** (string) - Required - The submission ID to reject. ### Request Example { "id": "sub_123" } ### Response #### Success Response (200) - **status** (string) - The new status, 'rejected'. #### Response Example { "status": "rejected" } ``` -------------------------------- ### Commission typed object schema (YAML) Source: https://github.com/affitor/open-affiliate/blob/main/docs/data-quality-audit.md Defines a structured commission object with an explicit mode, value, currency, duration, and raw source text. The 'mode: unknown' is key to making missing commission data honest and enabling CI to reject meaningless values like a bare '175'. ```yaml commission: mode: percentage | flat | hybrid | tiered | unknown value: 30 # null when mode is unknown currency: USD duration: 12 months raw: "30% recurring for 12 months" # what the source actually said ``` -------------------------------- ### POST /api/webhooks/github Source: https://github.com/affitor/open-affiliate/blob/main/docs/sdd-submit-rebuild.md Receives GitHub webhook events to update submission status based on PR merge, failure, or closure. ```APIDOC ## POST /api/webhooks/github ### Description Receives GitHub webhook events (pull_request and check_suite) to update submission status based on PR outcomes. Requires HMAC verification with GH_WEBHOOK_SECRET. ### Method POST ### Endpoint /api/webhooks/github ### Parameters #### Request Body - **event** (object) - Required - The GitHub webhook payload. ### Response #### Success Response (200) - **status** (string) - Confirmation of processing. #### Response Example { "status": "ok" } ``` -------------------------------- ### Commission Value: Percentage-based scoring formula Source: https://github.com/affitor/open-affiliate/blob/main/docs/affiliate-score.md Formula for scoring percentage-based commissions. A rate of 50% or higher yields the maximum 40 points; 25% yields 20 points; 10% yields 8 points. ```plaintext score = min(rate / 50, 1) * 40 ``` -------------------------------- ### Cookie Duration scoring formula Source: https://github.com/affitor/open-affiliate/blob/main/docs/affiliate-score.md Formula for scoring cookie duration. A duration of 90+ days yields the maximum 15 points; 30 days yields 5 points; 7 days yields approximately 1 point. ```plaintext score = min(cookie_days / 90, 1) * 15 ```