Devot:ee Purchased Items API for Commercial Developers

version 1.0.6

The developer Purchased Items API allows developers to request information from their account about items they've sold in JSON format via a secure request. If you are having trouble connecting (for example, you only get an "Authorization Required" message) please contact us so we can confirm your member account has the proper permissions.

Post Variables

The API expects two things: your API key and your secret key. The start and end date parameters are optional. If no dates are entered, your add-on sales info will go back a year by default. If you're a developer, your keys can be found on your main member page.

$api_key    = "a123ffa2345bfd6ee7f8cfe90c123e5"; // Your API key
$secret_key = "c1b2dd34afa567890a12bacfa34bc5a56df78"; // Your secret key
$start_dt   = "2011-01-01"; // (optional) Start Date (GMT)
$end_dt     = "2011-12-31"; // (optional) End Date for order requests (GMT)
// $end_dt is capped at a maximum of 1 year after $start_dt.

Legacy: For backwards compatibility, you can still use your devot:ee username and password to connect to the API, but we highly suggest you change any scripts you're currently using to use the keys.

$username = "username"; // Your username (legacy)
$password = "password"; // Your password (legacy)
$start_dt = "2011-01-01"; // (optional) Start Date (GMT)
$end_dt   = "2011-12-31"; // (optional) End date for order requests (GMT)
// $end_dt is capped at a maximum of 1 year after $start_dt.

Response Fields

For a valid login the API returns a JSON array containing the following:

start_dt - (int) Unix Timestamp for the start date of the request
end_dt - (int) Unix Timestamp for the end date of the request
count - (int) items returned by the request
items - (array)
    purchase_id - Unique ID for this purchase
    title - Product Title
    devotee_customer_id - Unique devot:ee member ID
    purchase_date - Date item was purchased (in Unix Timestamp format).
    item_status - One of two states: open or returned
    order_id - Unique ID for the Order that contains this item 
    order_number - The devot:ee order number
    quantity - Product Quantity
    price - Product Price
    license_key - UUID license key
    license_req - (y|n) whether the license key is required in configuration
    product_id - The devot:ee product ID
    internal_product_id - Your own unique ID for the product
    customer_email - Customer's Email 
    customer_billing_fname - Customer First Name 
    customer_billing_lname - Customer Last Name 
    customer_company - Company 

Example Usage

Below is some sample code (remember to wrap in PHP tags) for you to get started. Please note all the CURLOPT values, including the USERAGENT. Please note there should be no trailing slash on the API URL.

$api_key    = "a123ffa2345bfd6ee7f8cfe90c123e5"; // Your API key
$secret_key = "c1b2dd34afa567890a12bacfa34bc5a56df78"; // Your secret key
$start_dt  = "2012-01-01"; // start date in YYYY-MM-DD format
$end_dt    = "2012-03-30"; // end date in YYYY-MM-DD format

// Create the post string (Key version; recommended)
  $post_string = "api_key=".$api_key."&secret_key=".$secret_key."&start_dt=".$start_dt."&end_dt=".$end_dt;
// Create the post string (Username version; legacy, less secure)
//$post_string = "username=".$username."&password=".$password."&start_dt=".$start_dt."&end_dt=".$end_dt;

// Process 
  $url = "";
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS,$post_string);
  $response = urldecode(curl_exec($ch));
  $arr = json_decode($response,true);

// The order details are now available in an assoc array $arr

Example Output

Below is an example of what you might expect to see in the response (using print_r($arr);).

  [start_dt] => 1289449149
  [end_dt] => 1320731999
  [count] => 1
  [items] => Array
      [0] => Array
            [0] => Array
                  [purchase_id] => 21830
                  [title] => Super Kitchen Sink Add-on
                  [devotee_customer_id] => 12345
                  [purchase_date] => 1312491090
                  [item_status] => open
                  [order_id] => 37829
                  [order_number] => Order #11608
                  [quantity] => 1
                  [price] => 39.95
                  [license_key] => 28626544-b41e-4d54-82db-7e2a1b279c1e
                  [license_req] => y
                  [product_id] => 216
                  [internal_product_id] => D29647
                  [customer_email] =>
                  [customer_billing_fname] => Charlie
                  [customer_billing_lname] => Newbuck
                  [customer_company] => Three Chord Monte Inc.

Last updated September 15, 2014.