DEV Community

Alex Spinov
Alex Spinov

Posted on

Polar Has a Free API That Monetizes Your Open Source Project

Polar is the platform that lets open-source maintainers get paid. Sponsorships, paid issues, subscriptions, and digital products — all through a developer-first API.

What Is Polar?

Polar connects open-source work to revenue. Offer paid features, subscriptions, or bounties on issues. Get paid through Stripe with Polar handling the checkout flow.

The API

Authentication

export POLAR_TOKEN="your-api-token"

# Get your organization
curl -s 'https://api.polar.sh/v1/organizations' \
  -H "Authorization: Bearer $POLAR_TOKEN" | jq '.items[].name'
Enter fullscreen mode Exit fullscreen mode

Create a Product

curl -s -X POST 'https://api.polar.sh/v1/products' \
  -H "Authorization: Bearer $POLAR_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Pro API Access",
    "description": "Unlimited API calls + priority support",
    "prices": [{"type": "recurring", "recurring_interval": "month", "price_amount": 2900, "price_currency": "usd"}],
    "organization_id": "org-uuid"
  }'
Enter fullscreen mode Exit fullscreen mode

Create a Benefit (What Customers Get)

# GitHub repository access benefit
curl -s -X POST 'https://api.polar.sh/v1/benefits' \
  -H "Authorization: Bearer $POLAR_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
    "type": "github_repository",
    "description": "Access to private repo with pro features",
    "properties": {"repository_id": "repo-uuid", "permission": "pull"},
    "organization_id": "org-uuid"
  }'
Enter fullscreen mode Exit fullscreen mode

Generate Checkout Link

curl -s -X POST 'https://api.polar.sh/v1/checkouts/custom' \
  -H "Authorization: Bearer $POLAR_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"product_id": "prod-uuid"}' | jq '.url'
# Returns: https://polar.sh/checkout/...
Enter fullscreen mode Exit fullscreen mode

Verify Subscription in Your App

import { Polar } from '@polar-sh/sdk'

const polar = new Polar({ accessToken: process.env.POLAR_TOKEN! })

async function checkAccess(customerId: string): Promise<boolean> {
  const subs = await polar.subscriptions.list({
    customerId,
    active: true,
  })
  return subs.result.items.length > 0
}

// Middleware
app.use('/api/pro/*', async (req, res, next) => {
  const hasAccess = await checkAccess(req.user.polarCustomerId)
  if (!hasAccess) return res.status(403).json({ error: 'Pro subscription required' })
  next()
})
Enter fullscreen mode Exit fullscreen mode

Webhooks

import { validateEvent } from '@polar-sh/sdk/webhooks'

app.post('/webhooks/polar', async (req, res) => {
  const event = validateEvent(req.body, req.headers, process.env.POLAR_WEBHOOK_SECRET!)

  switch (event.type) {
    case 'subscription.created':
      await grantAccess(event.data.customer.email)
      break
    case 'subscription.canceled':
      await revokeAccess(event.data.customer.email)
      break
  }
  res.status(200).send('OK')
})
Enter fullscreen mode Exit fullscreen mode

Revenue Models Polar Supports

  • Subscriptions: monthly/yearly recurring
  • One-time purchases: digital products, templates
  • Pay-what-you-want: flexible pricing
  • GitHub repo access: automatic invite/revoke
  • Discord access: role management
  • License keys: auto-generated
  • File downloads: digital content delivery

Free Tier

Polar takes 0% platform fee on the free tier. You pay only Stripe processing fees (2.9% + $0.30).


Want to monetize your scraping tools? Scrapfly shows how API products generate revenue. Email spinov001@gmail.com for monetization strategy.

Top comments (0)