PHPackages                             thewpsquad/freemius-wp-rest - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. thewpsquad/freemius-wp-rest

ActiveLibrary[API Development](/categories/api)

thewpsquad/freemius-wp-rest
===========================

Reusable WP REST API proxy routes for the Freemius WordPress SDK — account, license, affiliate, pricing.

01↓50%PHPCI passing

Since Jun 12Pushed 1mo agoCompare

[ Source](https://github.com/thewpsquad/freemius-wp-rest)[ Packagist](https://packagist.org/packages/thewpsquad/freemius-wp-rest)[ RSS](/packages/thewpsquad-freemius-wp-rest/feed)WikiDiscussions trunk Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

freemius-wp-rest
================

[](#freemius-wp-rest)

Reusable WP REST API proxy routes for the [Freemius WordPress SDK](https://freemius.com/help/documentation/wordpress-sdk/).

Provides three ready-made route handlers — **Account**, **Affiliate**, and **Pricing** — that any WordPress plugin using Freemius can register by implementing a single interface.

---

Requirements
------------

[](#requirements)

- PHP 7.4+
- WordPress 6.0+
- Freemius WordPress SDK (bundled in the consuming plugin)

---

Installation
------------

[](#installation)

```
composer require thewpsquad/freemius-wp-rest
```

---

Usage
-----

[](#usage)

### 1. Implement `FreemiusProvider`

[](#1-implement-freemiusprovider)

```
use TheWPSquad\FreemiusRest\Contracts\FreemiusProvider;
use Freemius;
use Throwable;

class MyPluginFreemiusProvider implements FreemiusProvider {

    public function get_fs(): Freemius        { return my_fs(); }
    public function get_plugin_slug(): string { return 'my-plugin'; }
    public function get_rest_version(): string { return 'v2'; }
    public function get_capability(): string  { return 'manage_options'; }
    public function get_text_domain(): string { return 'my-plugin'; }
    public function get_cache_prefix(): string { return 'my_plugin_'; }

    public function log_error( Throwable $e, string $context ): void {
        // forward to your plugin's error logger
        error_log( "[{$context}] " . $e->getMessage() );
    }
}
```

### 2. Register routes inside `rest_api_init`

[](#2-register-routes-inside-rest_api_init)

```
add_action( 'rest_api_init', function () {
    $provider = new MyPluginFreemiusProvider();

    ( new \TheWPSquad\FreemiusRest\Routes\Account( $provider ) )->register();
    ( new \TheWPSquad\FreemiusRest\Routes\Affiliate( $provider ) )->register();
    ( new \TheWPSquad\FreemiusRest\Routes\Pricing( $provider ) )->register();
} );
```

Routes register under `{plugin_slug}/{rest_version}` — e.g. `my-plugin/v2`.

---

Endpoints
---------

[](#endpoints)

### Account — `GET /my-plugin/v2/account`

[](#account--get-my-pluginv2account)

Returns merged user + site + plan + license + boolean flags.

EndpointMethodDescription`/account`GETUser, site, plan, license, flags`/account/license`GETLicense detail + subscription + upgrade URL`/account/license/activate`POSTActivate a license key (`license_key`)`/account/license/deactivate/intent`POSTIssue a deactivation confirmation token`/account/license/deactivate`POSTExecute deactivation (`token`)`/account/tracking`POSTToggle Freemius usage tracking (`enabled`)### Affiliate — `GET /my-plugin/v2/affiliate`

[](#affiliate--get-my-pluginv2affiliate)

Cached 12 h. Clears on successful application.

EndpointMethodDescription`/affiliate`GETAffiliate status + programme terms`/affiliate/apply`POSTSubmit affiliate application### Payments — `GET /my-plugin/v2/payments`

[](#payments--get-my-pluginv2payments)

EndpointMethodDescription`/payments`GETPaginated payment history (cached 1 h). Params: `count` (1–50, default 20), `offset``/payments/{id}`GETSingle payment detail### Subscriptions — `GET /my-plugin/v2/subscriptions`

[](#subscriptions--get-my-pluginv2subscriptions)

EndpointMethodDescription`/subscriptions`GETActive subscriptions (cached 1 h)`/subscriptions/{id}/cancel`POSTCancel a subscription (`reason` optional)### Connect — `GET /my-plugin/v2/connect`

[](#connect--get-my-pluginv2connect)

EndpointMethodDescription`/connect`GETConnection status, flags, user, site, URLs`/connect/optin`POSTReturns opt-in redirect URL / triggers `connect_again()``/connect/skip`POSTSkip opt-in — set anonymous mode`/connect`DELETEDisconnect site from Freemius### Addons — `GET /my-plugin/v2/addons`

[](#addons--get-my-pluginv2addons)

EndpointMethodDescription`/addons`GETAll add-ons with activation state (SDK-first, cached 6 h)`/addons/{id}`GETSingle add-on detail### Trial — `GET /my-plugin/v2/trial`

[](#trial--get-my-pluginv2trial)

EndpointMethodDescription`/trial`GETTrial status, days remaining, eligibility, trial URL`/trial/start`POSTStart trial (`plan_id` required)### Notices — `GET /my-plugin/v2/notices`

[](#notices--get-my-pluginv2notices)

Notices are computed from live SDK state (not stored). Dismissed per-user via WordPress user meta.

EndpointMethodDescription`/notices`GETActive undismissed notices (license expiry, trial ending, not connected, etc.)`/notices/{id}/dismiss`POSTDismiss a notice for the current userNotice IDs: `not_connected`, `no_license`, `license_expiring`, `license_expired`, `trial_ending`, `pending_activation`

### Pricing — `GET /my-plugin/v2/pricing`

[](#pricing--get-my-pluginv2pricing)

No cache — always returns live prices.

EndpointMethodDescription`/pricing`GETAll plans + pricing tiers from Freemius---

`FreemiusProvider` interface
----------------------------

[](#freemiusprovider-interface)

MethodReturnsPurpose`get_fs()``Freemius`Initialised SDK instance`get_plugin_slug()``string`REST namespace prefix (`my-plugin`)`get_rest_version()``string`REST namespace version (`v2`)`get_capability()``string`WP capability gate (default `manage_options`)`get_text_domain()``string`Plugin text domain for translated error strings`get_cache_prefix()``string`Transient key prefix (`my_plugin_`)`log_error()``void`Error logging bridge to your plugin's logger---

License
-------

[](#license)

GPL-3.0-only — see [LICENSE](LICENSE).

###  Health Score

20

—

LowBetter than 12% of packages

Maintenance60

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/34349365?v=4)[Al Amin Ahamed](/maintainers/mralaminahamed)[@mralaminahamed](https://github.com/mralaminahamed)

---

Top Contributors

[![mralaminahamed](https://avatars.githubusercontent.com/u/34349365?v=4)](https://github.com/mralaminahamed "mralaminahamed (13 commits)")

---

Tags

affiliatecomposerfreemiusfreemius-sdklicense-managementphprest-apiwordpresswordpress-pluginwp-rest-api

### Embed Badge

![Health badge](/badges/thewpsquad-freemius-wp-rest/health.svg)

```
[![Health](https://phpackages.com/badges/thewpsquad-freemius-wp-rest/health.svg)](https://phpackages.com/packages/thewpsquad-freemius-wp-rest)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k18](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
