DEV Community

Alex Spinov
Alex Spinov

Posted on

Polar Has a Free API: Add Subscriptions and Donations to Your Open-Source Project in 10 Minutes

You built an open-source tool that thousands of developers use. Your GitHub repo has 2,000 stars. But your "Buy Me a Coffee" button generated $12 last year. The problem isn't that people don't want to support you — it's that existing monetization tools weren't built for developers. Polar was.

What Polar Actually Does

Polar is an open-source billing and monetization platform built specifically for developers and open-source maintainers. Think Stripe plus GitHub Sponsors, but with a developer-first API and features designed around how OSS projects actually work: issue funding, subscriptions, one-time donations, and digital product sales.

Polar is fully open-source (Apache 2.0) and can be self-hosted. Their hosted platform at polar.sh has no monthly fee — they take a small percentage of transactions only when you earn. The REST API is clean, well-documented, and secured with OAuth2 or API keys.

The critical difference from Patreon or Buy Me a Coffee: Polar integrates deeply with GitHub. You can fund specific issues, reward contributors automatically, and tie paid benefits to GitHub actions — like giving subscribers access to a private repo or Discord role.

Quick Start: Polar API

Get your API token from polar.sh → Settings → Developers → New Token.

export POLAR_TOKEN="your_token_here"

# List your products/subscription tiers
curl -s https://api.polar.sh/v1/products \
  -H "Authorization: Bearer $POLAR_TOKEN" | jq '.items[] | {id, name, price_amount}'
Enter fullscreen mode Exit fullscreen mode

Create a subscription tier:

curl -X POST https://api.polar.sh/v1/products \
  -H "Authorization: Bearer $POLAR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Pro Supporter",
    "description": "Support development + priority issue responses + private Discord access",
    "prices": [{
      "type": "recurring",
      "amount_type": "fixed",
      "price_amount": 900,
      "price_currency": "usd",
      "recurring_interval": "month"
    }]
  }'
Enter fullscreen mode Exit fullscreen mode

Check active subscribers:

curl -s "https://api.polar.sh/v1/subscriptions?active=true" \
  -H "Authorization: Bearer $POLAR_TOKEN" | jq '{
    total: .pagination.total_count,
    subscribers: [.items[] | {email: .customer.email, tier: .product.name}]
  }'
Enter fullscreen mode Exit fullscreen mode

3 Practical Use Cases

1. GitHub Issue Funding

Polar's flagship feature: let users pledge money to get specific bugs fixed. When you close a funded issue, contributors get paid automatically.

curl -s "https://api.polar.sh/v1/issues?organization=YOUR_ORG&repository=YOUR_REPO&is_badged=true" \
  -H "Authorization: Bearer $POLAR_TOKEN" | jq '.items[] | {
    title: .title,
    funding_goal: .funding.funding_goal.amount,
    pledged: .funding.pledges_sum.amount
  }'
Enter fullscreen mode Exit fullscreen mode

Add a funding badge to your README:

[![Fund with Polar](https://polar.sh/embed/fund-label.svg?org=your-org)](https://polar.sh/your-org)
Enter fullscreen mode Exit fullscreen mode

When you merge a PR that closes a funded issue, Polar handles reward distribution automatically.

2. Automate Subscriber Benefits with Webhooks

Polar fires webhooks on subscription events. Grant GitHub repo access automatically on new subscription:

const express = require('express');
const app = express();

app.post('/polar/webhook', express.raw({type: 'application/json'}), async (req, res) => {
  const event = JSON.parse(req.body);

  if (event.type === 'subscription.created') {
    const githubUsername = event.data.customer.metadata?.github_username;
    if (githubUsername) {
      await fetch(`https://api.github.com/repos/YOUR_ORG/premium-content/collaborators/${githubUsername}`, {
        method: 'PUT',
        headers: { 'Authorization': `token ${process.env.GITHUB_TOKEN}` },
        body: JSON.stringify({ permission: 'pull' })
      });
    }
  }

  if (event.type === 'subscription.revoked') {
    const github = event.data.customer.metadata?.github_username;
    await fetch(`https://api.github.com/repos/YOUR_ORG/premium-content/collaborators/${github}`, {
      method: 'DELETE',
      headers: { 'Authorization': `token ${process.env.GITHUB_TOKEN}` }
    });
  }

  res.sendStatus(200);
});
Enter fullscreen mode Exit fullscreen mode

Automatic access management — no manual work, no forgotten cancellations.

3. Checkout Links for Digital Products

Sell docs, templates, or premium extensions with one-click checkout:

curl -X POST https://api.polar.sh/v1/checkouts/custom \
  -H "Authorization: Bearer $POLAR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "product_id": "YOUR_PRODUCT_ID",
    "success_url": "https://yoursite.com/thank-you?checkout_id={CHECKOUT_ID}",
    "customer_email": "user@example.com",
    "metadata": { "source": "readme_cta" }
  }' | jq '{ checkout_url: .url, expires_at: .expires_at }'
Enter fullscreen mode Exit fullscreen mode

Drop the URL in your README, docs, or email. Each click goes to a frictionless checkout.

Why This Matters

Open-source sustainability is broken. Polar is the first platform that truly understands the developer workflow: GitHub-centric, API-first, developer-controlled. The issue funding model changes the entire dynamic — instead of hoping people donate, you give them a direct line to influence your roadmap.

For SaaS developers, Polar also competes with Stripe Billing for simple subscription needs — with zero monthly platform fee and developer experience that feels designed by engineers, not product managers. If you maintain any open-source project with real users, set up Polar before you burn out.


Need custom data extraction or web scraping solutions? I build production-grade scrapers and data pipelines. Check out my Apify actors or email me at spinov001@gmail.com for custom projects.

Follow me for more free API discoveries every week!

Top comments (0)