Reporting API
Instructions for generating reports using the Reporting API.
To get started using the Lootably Reporting API you will need to grab your apiKey from the "API" tab inside any of your placement's settings on the Lootably Publisher Dashboard. All placements in your account share the same API key. All Reporting API requests are sent as a POST request to https://api.lootably.com/api/v2/report/generate
const API_URL = 'https://api.lootably.com/api/v2/report/generate';
type SuccessfulAPIResponse = {
success: true,
data: (ConversionsReportItem | MonthlyReportItem | DailyReportItem | CountryReportItem)[],
};
type FailedAPIResponse = {
success: false,
message: string,
};
async function generateReport(): Promise<void> {
const requestBody = {
apiKey: process.env.API_KEY,
startingDate: '2024-12-01T00:00:00',
endingDate: '2025-01-31T23:59:59',
reportType: 'conversions',
// Optional: Include placementID if you want to filter by a specific placement
// placementID: 'your-placement-id'
};
const response = await fetch(API_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestBody),
});
const data: SuccessfulAPIResponse | FailedAPIResponse = await response.json();
if (data.success) {
console.log('Report Data:', data.data);
} else {
console.error(`Error: ${data.message}`);
}
}
generateReport().catch((error) => {
console.error('An error occurred while generating report:', error);
});
The Reporting API accepts the following parameters in the JSON body:
Key | Type | Description |
---|---|---|
apiKey | String | Your publisher account's API key |
startingDate | String | An ISO-formatted date string. For example: "2024-12-01T00:00:00" |
endingDate | String | An ISO-formatted date string. For example: "2024-12-01T00:00:00" |
reportType | String | The type of report your would like to generate. Accepted values: - conversions - dailyRevenue - monthlyRevenue - countryRevenue |
placementID | String (optional) | If you would like to narrow your report to a specific placement, you can pass an optional placementID value |
Response structure
All report types return an array of objects, but the structure of the objects varies between report types. Here is the general response structure you can expect:
{
"success": true,
"data": [
...
]
}
Conversion Report Item type
type ConversionsReportItem = {
// The reward amount in your placement's currency
currencyReward: number;
// The IP address associated with the transaction
ip: string;
// The unique identifier for the offer
offerID: string;
// The name of the offer
offerName: string;
// Indicates if the postback has successfully been sent and acknowledged by your server
postbackComplete: boolean;
// Number of postback attempts
postbackTries: number;
// The amount of revenue generated
revenue: number;
// The timestamp for the transaction (ISO format)
time: string;
// Unique identifier for the transaction
transactionID: string;
// Unique identifier for the user
userID: string;
};
Monthly Revenue Report Item type
type MonthlyReportItem = {
// The month and year of the report (MM-YYYY format)
time: string;
// The total number of conversions during the period
totalConversions: number;
// The total revenue generated during the period
totalRevenueGenerated: number;
};
Daily Revenue Report Item type
type DailyReportItem = {
// The month and year of the report (MM-YYYY format)
time: string;
// The total number of conversions during the period
totalConversions: number;
// The total revenue generated during the period
totalRevenueGenerated: number;
};
Country Report Item type
type CountryReportItem = {
// The country code in ISO 3166-1 alpha-2 format
countryCode: string;
// The total revenue generated from this country during the period
revenue: number;
// The total number of conversions from this country during the period
totalConversions: number;
};
Updated 3 days ago