MediaGrabber Pro

Quickstart

Activate your first license in under 5 minutes.

This quickstart gets a license validating from your plugin code as fast as possible. If you'd rather understand the system first, read Core Concepts.

Before you begin

You need three things: a running portal (this app), a customer account with at least one license, and Node.js 20 or newer in your plugin's runtime.

  • Node.js 20+ in the environment where your plugin runs
  • A portal deployment reachable over HTTPS (yours, or http://localhost:3001 in dev)
  • A license key — created automatically after checkout, visible on the customer's Licenses page

Five minutes to a working license

Install the SDK

npm install @theplugins/license-sdk
# or: pnpm add @theplugins/license-sdk

The SDK is framework-agnostic ESM with no required dependencies. It runs in Node servers, serverless/edge functions, and WordPress sidecars.

Point it at your portal

import { LicenseClient } from '@theplugins/license-sdk'
 
const client = new LicenseClient({
  apiUrl: process.env.LICENSE_API_URL ?? 'https://licenses.yourplugin.com',
})

Keep apiUrl in an environment variable so you can switch between staging and production without touching code.

Activate on first run

Activation ties a license key to this install via a stable fingerprint.

const result = await client.activate({
  licenseKey: 'LK-2025-XXXX-YYYY', // from the customer's dashboard
  fingerprint: generateFingerprint(), // stable id for this device/site
  domain: 'acmecorp.com',            // optional, shown in the portal
  label: 'Production server',        // optional, human label
})
 
if (!result.ok) {
  console.error('Activation failed:', result.error)
  process.exit(1)
}
 
// Persist this so you can skip re-activation on restart
const connectionId = result.data.connectionId

See Activation for how to generate a stable fingerprint.

Validate on startup

const valid = await client.validate({
  licenseKey: 'LK-2025-XXXX-YYYY',
  fingerprint: storedFingerprint,
})
 
if (!valid.ok || !valid.data.active) {
  throw new Error('License invalid or expired')
}
 
console.log('Plan:', valid.data.plan.name)

The result is cached locally, so this adds no latency to normal requests.

(Optional) Report metered usage

If the plan is metered, report usage after each chargeable operation:

const usage = await client.reportUsage({
  licenseKey: 'LK-2025-XXXX-YYYY',
  metric: 'api_requests',
  quantity: 1,
})
 
if (!usage.ok || !usage.data.allowed) {
  throw new Error('Plan limit reached for this period')
}

What's next

On this page

Quickstart | MediaGrabber Pro