NAV
cURL PHP

Introduction

Welcome to the WP Rocket Reseller API documentation!

WP Rocket is a WordPress premium caching plugin that provides both lightning speed for your website and easy set up for you.

If you are a webhosting company, or if you want to offer WP Rocket to customers as part of a site optimization service (for example), our reseller program allows you to purchase Personal licenses at 20% off to sell to your customers.

When you resell a license through our API, we automatically generate an account for that customer in our system and they are the owner of the license.

Authentication

All API requests must be sent over HTTPS. An App ID and API Key must be included in the request - Basic Authentication is used to submit these details, where the App ID and the API key should be used as the parameters.

Orders

Order Model

Attribute Type Description
order array List of customer infos. See Order properties
customer array List of customer infos. See Customer properties
licence array List of license infos. See License properties
plugin string The link to download the plugin zip

Order Properties

Attribute Type Description
id integer Order ID
paid_date timestamp Timestamp when the order was paid
currency integer Currency in ISO format, e.g USD
total integer Order total

Customer Properties

Attribute Type Description
id integer Customer ID
email string Customer email
first_name string Customer first name
last_name string Customer last name

Licence Properties

Attribute Type Description
version string Licence version
first_name timestamp Licence date expiration

Create an Order

This endpoint helps you to create a new order.

POST
https://wp-rocket.me/api/v2/reseller/orders
Parameter Type Description
email string The email of the customer required
first_name string The first name of the customer required
last_name string The last name of the customer required
billing_country string The country of the customer.
Format: ISO 3166-1 alpha-2
customer_id int The customer ID
licence string The licence to give to the customer.
Defaults to single.
By default are available the licences: single, plus, infinite, renew
force bool Force the new licence to be combined with current one.
Defaults to false.
For example, if the customer has a business license and you want to offer him a new Single license (3+1 = 4 websites)
curl -X POST https://wp-rocket.me/api/v2/reseller/orders
  -u reseller_app_id:reseller_api_key \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' -d '
{
  "email": "[email protected]",
  "first_name": "John",
  "last_name": "Doe",
  "customer_id": 123456,
  "licence": "single",
  "force": false
}'
<?php
$wp_rocket = new WP_Rocket_Reseller( 'YOUR_APP_ID', 'YOUR_API_Key' );
$wp_rocket->createOrder( '[email protected]', 'John', 'Doe' );
?>

Response:

{
    "type": "order.create",
    "order": {
        "id": 52982,
        "paid_date": 1432577572,
        "currency": "USD",
        "total": "31.20"
    },
    "customer": {
        "id": 123456,
        "email": "[email protected]",
        "first_name": "John",
        "last_name": "Doe"
    },
    "licence": {
        "version": "2.5.12",
        "date_expiration": 1464192770
    },
    "plugin": "http:\/\/support.wp-rocket.me\/johndoe\/wp-rocket-X.zip",
    "error": false,
    "status": 200
}

View an Order

This endpoint lets you retrieve and view a specific order.

HTTP Request

GET
https://wp-rocket.me/api/v2/reseller/orders/<id>

URL Parameters

Parameter Type Description
ID integer The ID of the order to retrieve required
curl https://wp-rocket.me/api/v2/reseller/orders/52982
  -u reseller_app_id:reseller_api_key \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
<?php
$wp_rocket = new WP_Rocket_Reseller( 'YOUR_APP_ID', 'YOUR_API_Key' );
$order = $wp_rocket->getOrder($id);
?>

Response:

{
    "type": "order",
    "order": {
        "id": 52982,
        "paid_date": 1432577572,
        "currency": "USD",
        "total": "31.20"
    },
    "customer": {
        "id": 123456,
        "email": "[email protected]",
        "first_name": "John",
        "last_name": "Doe"
    },
    "licence": {
        "version": "2.5.12",
        "date_expiration": 1464192770
    },
    "plugin": "http:\/\/support.wp-rocket.me\/johndoe\/wp-rocket-X.zip",
    "error": false,
    "status": 200
}

List Orders

This endpoint retrieves all orders.

The order list is ordered descending, most recently created first.

HTTP Request

GET
https://wp-rocket.me/api/v2/reseller/orders
curl https://wp-rocket.me/api/v2/reseller/orders
  -u reseller_app_id:reseller_api_key \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
<?php
$wp_rocket = new WP_Rocket_Reseller( 'YOUR_APP_ID', 'YOUR_API_Key' );
$orders = $wp_rocket->getOrders();
?>

Response:

{
    "type": "order.list",
    "orders": [
        {
            "order": {
                "id": 52982,
                "paid_date": 1432577572,
                "currency": "USD",
                "total": "31.20"
            },
            "customer": {
                "id": 123456,
                "email": "[email protected]",
                "first_name": "John",
                "last_name": "Doe"
            },
            "licence": {
                "version": "2.5.12",
                "date_expiration": 1464192770
            },
            "plugin": "http:\/\/support.wp-rocket.me\/johndoe\/wp-rocket-X.zip"
        },
        {},
        {}
    ],
    "error": false,
    "status": 200
}

Count Orders

This endpoint helps you to get all orders total.

GET
https://wp-rocket.me/api/v2/reseller/orders/count
curl https://wp-rocket.me/api/v2/reseller/orders/count
  -u reseller_app_id:reseller_api_key \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
<?php
$wp_rocket = new WP_Rocket_Reseller( 'YOUR_APP_ID', 'YOUR_API_Key' );
$orders = $wp_rocket->getOrdersCount();
?>

Response:

{
    "type": "order.count",
    "orders": 10,
    "error": false,
    "status": 200
}

Integrations

WooCommerce

If you are selling your optimization service with WooCommerce, you can implement our Reseller API by following this example integration.

Please select PHP mode to view the example code!
<?php
add_action( 'woocommerce_order_status_completed', '_maybe_call_wp_rocket_api', PHP_INT_MAX );
function _maybe_call_wp_rocket_api( $order_id ) {
    $order    = new WC_Order( $order_id );
    $products = $order->get_items();

    // You can check if a specific product was bought until to call the WP Rocket Reseller API
    if( in_array( 6457, wp_list_pluck( $products, 'product_id' ) ) ) {
        $wp_rocket = new WP_Rocket_Reseller( 'YOUR_APP_ID', 'YOUR_API_Key' );
        $wp_rocket_order = $wp_rocket->createOrder(
            $order->billing_email,
            $order->billing_first_name,
            $order->billing_last_name
        );

        // Get download plugin link
        $plugin = $wp_rocket_order->plugin;
    }
}
?>