Skip to content

About

One PHP file, no dependencies, for working with the AffiliatePipe Partner API and the APIs of the programs you promote.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-api-kit

One PHP file, no dependencies, for working with the AffiliatePipe Partner API and the APIs of the programs you promote.

  • Partner API: your stats, sales, programs and tracking links.
  • Any product API: a small JSON client with Bearer or custom header keys.
  • Nothing hard-coded: the program list is pulled from your account at run time, so new programs show up on their own.

Needs PHP 8.1+ with curl. No Composer, no framework.

Install

Copy src/ApiKit.php into your project and require it.

require 'ApiKit.php';

Your key

Make a key under API in your AffiliatePipe dashboard. Keys start with ap_live_. Keep it on the server; never put it in browser code.

export AFFILIATEPIPE_KEY=ap_live_xxxxxxxx

Partner API

$ap = ApiKit\Partner::fromEnv();      // or new ApiKit\Partner('ap_live_...')

$ap->programs();                      // open programs, your links, your audience code
$ap->stats('7d');                     // today, 7d, 30d or month
$ap->conversions(25, 'approved');     // pending, approved, paid, clawed_back
foreach ($ap->allConversions() as $sale) { /* every page */ }
$ap->link('https://example.com/pricing');

List every program you can promote

foreach ($ap->programs() as $p) {
    echo $p['domain'], "\n";
}

Earnings in a Discord message

$s = $ap->stats('today');
file_get_contents(getenv('DISCORD_WEBHOOK'), false, stream_context_create(['http' => [
    'method'  => 'POST',
    'header'  => 'Content-Type: application/json',
    'content' => json_encode(['content' => 'Today: ' . json_encode($s)]),
]]));

Any product API

Each program has its own API and its own key. Take the base URL and auth style from that product's documentation.

$api = ApiKit\Client::bearer('https://api.example.com/v1', getenv('PRODUCT_KEY'));
$api = ApiKit\Client::header('https://api.example.com/v1', 'X-API-Key', getenv('PRODUCT_KEY'));

$rows = $api->get('/items', ['limit' => 10]);

Errors throw ApiKit\ApiError, with ->status and ->body.

Command line

bin/apikit health
bin/apikit programs
bin/apikit stats 7d
bin/apikit conversions approved
bin/apikit link https://example.com/pricing

Examples

File What it does
examples/programs.php Prints every open program with its rate and your link
examples/stats.php Your numbers for a period
examples/conversions.php Every sale, across all pages
examples/link.php A tracking link for a product page
examples/product_api.php Calls any product's own API

Not a partner yet?

Joining is free and one application opens every program, with recurring commission paid monthly. Apply at affiliatepipe.com.

There is also an MCP server at https://affiliatepipe.com/mcp that takes the same key, if you would rather ask an AI assistant for your numbers.

Licence

MIT

About

One PHP file, no dependencies, for working with the AffiliatePipe Partner API and the APIs of the programs you promote.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages