Appearance
Public API Overview
The Public API is designed for integration into your distributed product. Use it to validate licenses, handle activations, serve updates, collect feedback, and track analytics.
Base URL: https://api.packedge.dev/public/v1
Integration Options
| Method | Package | Best For |
|---|---|---|
| JS SDK | packedge | Frontend, WordPress plugins |
| PHP SDK | packedge-sdk/license | PHP backends, WordPress |
| REST API | — | Any language, custom needs |
JS SDK
Install via package manager (pnpm recommended):
bash
pnpm add packedgebash
npm install packedgebash
yarn add packedgebash
bun add packedgejavascript
import packedge from 'packedge';
packedge.init('pk_your_public_key');
// Validate license (site auto-detected from browser)
const result = await packedge.validateLicense('LICENSE-KEY');
// Or specify site manually
const result = await packedge.validateLicense('LICENSE-KEY', { site: 'https://example.com' });
// Activate license
await packedge.activateLicense('LICENSE-KEY');
// Track feature usage
packedge.track('feature_used', { feature: 'export' });
// Submit feedback
await packedge.submitFeedback({ type: 'bug', message: 'Button broken' });Or via CDN (non-WordPress contexts):
html
<script src="https://cdn.packedge.dev/packedge.js"></script>
<script>
packedge.init('pk_your_public_key');
</script>WordPress
WordPress doesn't allow remote scripts. Use the ES6 module approach with a bundler instead.
PHP SDK
bash
composer require packedge-sdk/license
composer require packedge-sdk/analyticsphp
use PackEdge\License;
use PackEdge\Analytics;
// License validation + auto-updates
$license = License::init('pk_your_public_key', __FILE__);
if ($license->is_valid()) {
// Enable premium features
}
// Auto-updates (call once)
$license->updater();
// Analytics + feedback (separate package)
$analytics = Analytics::init('pk_your_public_key', __FILE__);
// Track feature usage
$analytics->track('feature_used', ['feature' => 'export']);
// Submit feedback
$analytics->feedback('bug', 'Button broken', 'user@example.com');REST API
bash
curl -X POST https://api.packedge.dev/public/v1/licenses/validate \
-H "Content-Type: application/json" \
-d '{"public_key": "pk_your_key", "license_key": "XXX", "site": "example.com"}'Authentication
Pass your public_key in the request body (REST) or constructor (SDK). This key is safe to embed in distributed code — it only identifies your product and cannot modify data.
php
// REST API example
$response = wp_remote_post('https://api.packedge.dev/public/v1/licenses/validate', [
'body' => json_encode([
'public_key' => 'pk_your_public_key', // Safe to embed
'license_key' => $customer_license,
]),
]);Public Key vs API Key
| Public Key | API Key | |
|---|---|---|
| Prefix | pk_ | sk_ |
| Purpose | Identify product in customer apps | Manage resources from your backend |
| Safe to embed | Yes | No (secret) |
| Can validate licenses | Yes | Yes |
| Can create/modify data | No | Yes |
Endpoints
Licenses
Let customers validate and manage their license activations.
- Validate — Check license validity and status
- Activate — Activate on a domain/device
- Deactivate — Release an activation slot
- Check — Quick activation status check
WordPress Updates
Power automatic updates in WordPress plugins.
- Update Check — Check for new versions
- Download — Download release ZIP
Feedback & Analytics
Collect user feedback and track product usage.
- Submit Feedback — Bug reports, feature requests, general feedback
- Track Event — Feature usage, behavior analytics
- Track Deactivation — Capture reason when license deactivated
Error Handling
All endpoints return standard HTTP status codes:
| Status | Meaning |
|---|---|
200 | Success |
400 | Bad request — invalid parameters or business logic error |
404 | Not found — invalid public_key or license_key |
Error responses include an error field:
json
{
"error": "License has expired"
}Caching
Edge endpoints run on Cloudflare Workers with KV caching:
- Validation responses cached for 60 seconds
- Update check responses cached for 5 minutes
- Cache invalidated on activation/deactivation
Rate Limits
Standard Cloudflare Workers rate limits apply. The KV caching layer minimizes database load for high-volume validation.
