GET https://api.infrhq.com/partner_project/query/retrieve (opens in a new tab)
The query API can be employed to get relevant metrics about earnings, ads and other data. The query API is a RESTful API that uses JSON as its communication format. The query API is designed to be used by developers to build applications that can interact with the InfrHQ platform.
Headers
Infr-Secret: Your secret API Key. This is used to authenticate your request. Do not share this key with anyone, or expose it in a client-side application.
Parameters
start_date (optional): The start date of the query. This is the unix timestamp in seconds. Defaults to start of month.
end_date (optional): The end date of the query. This is the unix timestamp in seconds. Defaults to end of month.
page (optional): The page number of the query. Defaults to 0, each page contains at most 50 results.
attribute_query (optional): An attribute query to filter by key, vals shared during the get ad calls.
advert_id (optional): A specific advert id to retrieve.
Response
The response is a list of objects, each containing information about an advert, its context, and metrics.
Advert Object
A unique identifier for the advert.
An object containing the advert's information.
Metadata related to the advert.
Attributes Object
An object containing the attributes associated with the request.
Context Object
An object containing the context information.
Metrics Object
An object containing the metrics associated with the advert.
Code Sample
let base_uri = "https://api.infrhq.com/partner_project/query/retrieve";
let secret_key = "YOUR_SECRET_KEY"; // Your secret API Key. (e.g infr_sk_...)
let start_date = 0; // The start date of the query. This is the unix timestamp in seconds. Defaults to start of month.
let end_date = 1683494060 // The end date of the query. This is the unix timestamp in seconds. Defaults to end of month.
let page = 0; // The page number of the query. Defaults to 0, each page contains at most 50 results.
let attribute_query = {"user_id": 1234} // Filter where the user_id is 1234
var my_headers = new Headers();
my_headers.append("Infr-Secret", secret_key);
var requestOptions = {
method: 'GET',
headers: my_headers,
redirect: 'follow'
};
fetch( `${base_uri}?start_date=${start_date}&end_date=${end_date}&page=${page}&attribute_query=${JSON.stringify(attribute_query)}`
requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
[
{
"advert": {
"_id": "advert_wcjqxtyt9h6v4xb2",
"info": {
"description": "Discover Plasmic.app, the revolutionary visual design and development tool that simplifies the process of creating stunning and responsive designs. With its drag-and-drop interface, real-time collaboration features, and automatic code generation, Plasmic.app is the perfect tool for elevating your style and creating a sustainable wardrobe. Join the movement and start crafting beautiful and ethical designs today!",
"image": "https://res.cloudinary.com/dcwz20wdd/image/upload/v1682769182/stage/image_rc0b9ln55sdpk7ms.jpg",
"link": "https://api.infrhq.com/c/6qa4xitwqlbe",
"title": "Elevate Your Style with Plasmic.app"
},
"meta": {
"date_created": 1683544786
}
},
"attributes": null,
"context": {
"backdrop": "A user is browsing a fashion and lifestyle blog that features the latest trends, outfit ideas, and product reviews. They have recently shown interest in sustainable fashion and have a history of engaging with articles about minimalist wardrobes and ethical brands.",
"system_message": "Create an eye-catching and visually appealing desktop screen banner advertisement optimized for a 1200x400 pixel resolution."
},
"metrics": {
"earning": 0.213445
}
}
]