How the business is doing over a period
curl --request GET \
--url https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/insights \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/insights"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/insights', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/insights",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$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://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/insights"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/insights")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/insights")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"status": {
"ok": true,
"code": 123,
"desc": "<string>"
},
"data": {
"period": {
"from": "2023-11-07T05:31:56Z",
"to": "2023-11-07T05:31:56Z",
"interval": "day",
"till_scoped": true
},
"totals": {
"collected": 123,
"collected_net": 123,
"fees": 123,
"collections": 123,
"failed": 123,
"success_rate": 123,
"payers": 123,
"avg_ticket": 123,
"paid_out": 123,
"payouts": 123,
"settled": 123,
"settlements": 123,
"net_flow": 123
},
"previous": {
"collected": 123,
"collected_net": 123,
"fees": 123,
"collections": 123,
"failed": 123,
"success_rate": 123,
"payers": 123,
"avg_ticket": 123,
"paid_out": 123,
"payouts": 123,
"settled": 123,
"settlements": 123,
"net_flow": 123
},
"series": [
{
"start": "2023-11-07T05:31:56Z",
"collected": 123,
"paid_out": 123,
"settled": 123,
"collections": 123,
"payouts": 123,
"new_payers": 123,
"returning_payers": 123
}
],
"by_till": [
{
"till_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"collected": 123,
"collections": 123
}
],
"by_rail": [
{
"provider": "mpesa",
"method": "stk",
"collected": 123,
"collections": 123
}
],
"top_payers": [
{
"payer": "<string>",
"collected": 123,
"collections": 123,
"last_paid_at": "2023-11-07T05:31:56Z"
}
],
"heatmap": [
{
"dow": 123,
"hour": 123,
"collected": 123,
"collections": 123
}
],
"customers": {
"new": 123,
"returning": 123,
"cohorts": [
{
"month": "2023-11-07T05:31:56Z",
"size": 123,
"retained": [
123
]
}
]
}
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}Merchant API
How the business is doing over a period
Totals for from..to and for the equal window before it (previous, for “vs last period”), a zero-filled
series, money in by till and by rail, the top 10 payers, a day-of-week x hour heatmap, new vs returning payers
and the last 6 monthly cohorts. Collections count when completed; success rate is completed / (completed + failed).
Times bucket in the operator’s time zone (Africa/Nairobi). Payouts and settlements are merchant-wide, so they are
zero when the view is narrowed to a till (till_id, or a cashier pinned to theirs; period.till_scoped). Needs read.
GET
/
v1
/
merchants
/
{merchantID}
/
insights
How the business is doing over a period
curl --request GET \
--url https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/insights \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/insights"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/insights', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/insights",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$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://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/insights"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/insights")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/insights")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"status": {
"ok": true,
"code": 123,
"desc": "<string>"
},
"data": {
"period": {
"from": "2023-11-07T05:31:56Z",
"to": "2023-11-07T05:31:56Z",
"interval": "day",
"till_scoped": true
},
"totals": {
"collected": 123,
"collected_net": 123,
"fees": 123,
"collections": 123,
"failed": 123,
"success_rate": 123,
"payers": 123,
"avg_ticket": 123,
"paid_out": 123,
"payouts": 123,
"settled": 123,
"settlements": 123,
"net_flow": 123
},
"previous": {
"collected": 123,
"collected_net": 123,
"fees": 123,
"collections": 123,
"failed": 123,
"success_rate": 123,
"payers": 123,
"avg_ticket": 123,
"paid_out": 123,
"payouts": 123,
"settled": 123,
"settlements": 123,
"net_flow": 123
},
"series": [
{
"start": "2023-11-07T05:31:56Z",
"collected": 123,
"paid_out": 123,
"settled": 123,
"collections": 123,
"payouts": 123,
"new_payers": 123,
"returning_payers": 123
}
],
"by_till": [
{
"till_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"collected": 123,
"collections": 123
}
],
"by_rail": [
{
"provider": "mpesa",
"method": "stk",
"collected": 123,
"collections": 123
}
],
"top_payers": [
{
"payer": "<string>",
"collected": 123,
"collections": 123,
"last_paid_at": "2023-11-07T05:31:56Z"
}
],
"heatmap": [
{
"dow": 123,
"hour": 123,
"collected": 123,
"collections": 123
}
],
"customers": {
"new": 123,
"returning": 123,
"cohorts": [
{
"month": "2023-11-07T05:31:56Z",
"size": 123,
"retained": [
123
]
}
]
}
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}Authorizations
merchantKeybearer & merchantId