Subscription Management
Get subscription contract analytics and revenue metrics
Returns how many orders a subscription contract has placed and their total amount. This is an Admin API endpoint: call it from your server, never from a storefront or the customer’s browser.
Response fields
totalOrderCount(integer): the contract’s first order, when the contract has an order ID, plus each billing attempt with the statusSUCCESSand an order amount. Queued, skipped and failed billing attempts aren’t counted. A contract created without an order has no first order to count.totalOrderAmount(number, ornull): the sum of the counted orders’ amounts, in the shop’s currency. It isnullwhen no counted order has an amount.totalOrderRevenue(string):totalOrderAmountin the shop’s money format, such as$16.20. WhentotalOrderAmountisnull, it is zero in that format, such as$0.00.
Use totalOrderAmount for calculations and totalOrderRevenue for display.
Errors
- An unknown contract ID, or a contract that belongs to another store, returns
400with theerrorKeyinvalidContract. - A missing or invalid API key returns
401.
Authentication: Requires a valid X-API-Key header. A Read only key works.
GET
/
api
/
external
/
v2
/
subscription-contract-details
/
analytics
/
{contractId}
Get subscription contract analytics and revenue metrics
curl --request GET \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}';
const options = {method: 'GET'};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"totalOrderAmount": 16.2,
"totalOrderCount": 1,
"totalOrderRevenue": "$16.20"
}Path Parameters
Response
Successfully retrieved contract analytics
⌘I
Get subscription contract analytics and revenue metrics
curl --request GET \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}';
const options = {method: 'GET'};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/analytics/{contractId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"totalOrderAmount": 16.2,
"totalOrderCount": 1,
"totalOrderRevenue": "$16.20"
}