Sample Revenue Metrics API Requests
Node.js Example
const fetch = require('node-fetch');
async function fetchRevenueMetrics(apiKey, dateFrom, dateTo) {
const url = "https://universal-api.myappfree.com/graphql/index.html";
const headers = {
"x-api-key": apiKey,
"Content-Type": "application/json"
};
const query = {
query: `
query RevenueMetrics($fromDate: String!, $toDate: String!) {
revenueMetrics(where: { dateFrom: $fromDate, dateTo: $toDate }) {
total
items {
siteId
siteName
adunitId
adunitName
impressions
clicks
revenue
ecpm
arpdau
dau
}
}
}`,
variables: {
fromDate: dateFrom,
toDate: dateTo
}
};
const response = await fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(query)
});
if (response.ok) {
const data = await response.json();
return data;
} else {
throw new Error(`Query failed with status ${response.status}: ${await response.text()}`);
}
}
// Usage example
const apiKey = "YOUR_API_KEY";
const dateFrom = "2025-01-10 00:00:00";
const dateTo = "2025-01-10 10:00:00";
fetchRevenueMetrics(apiKey, dateFrom, dateTo)
.then(data => {
console.log("Revenue Metrics:");
console.log(JSON.stringify(data, null, 2)); // Pretty print the response with indentation
})
.catch(err => console.error("Error:", err));Python Example
C# Example
Shell Example
Last updated