The OptiMonk Public API allows you to access various aspects of your OptiMonk account, including campaign details, leads, account information, and reports. It helps you connect your favorite reporting tool and create a custom dashboard that shows your OptiMonk campaign results in an easy-to-understand way.
Here are the key metrics that you can effortlessly retrieve and display on your custom dashboard using our Reporting API:
- Conversions: Track the number of successful conversions your OptiMonk campaigns are generating.
- Impressions: Measure the total number of times your campaigns have been shown to your visitors.
- Conversion Rate: Understand the effectiveness of your campaigns by calculating the conversion rate, which is the percentage of visitors who achieve a conversion event.
- Subscribers: Monitor the growth of your subscriber list directly from your custom dashboard.
- Visitor Limit: Keep tabs on the number of visitors your website is reaching, helping you make informed decisions about your campaign strategy.
In this guide, you'll find
1. How to generate an API key in OptiMonk
2. OptiMonk Public API Documentation
1. How to generate an API key in OptiMonk
To seamlessly integrate and access your campaign data via the Reporting API, follow these simple steps:
1. Log in to you OptiMonk account at https://app.optimonk.com/login/en
2. Click on your account menu at the bottom of the left navbar and select Settings.
3. Here, under Account, you'll find API keys.
4. Click on Generate API key on this page. Your API key will be shown right away and it will be ready for you to copy.
2. OptiMonk Public API Documentation
At this point, you may require the assistance of a developer to help you create a customized integration. Kindly share our OptiMonk Public API documentation with them.
2.1 Overview
This documentation provides information on available endpoints, parameters, responses, and authentication.
Base URL: https://api.optimonk.com/v1
2.2 Authentication
All requests to the Optimonk Public API must include an API key in the x-api-key header.
2.3 Endpoints
2.3.1 Overall Campaign Details
GET /v1/campaigns/
- Description: Retrieve overall campaign details.
- Parameters:
- page (optional): Pagination index (default: 1).
- Headers:
- x-api-key: API key generated for your account.
- Responses:
- 200 OK: Overall campaign statistics.
- 400 Bad Request: Request is not valid.
- 401 Unauthorized: Provided API key is not valid.
- 406 Not Acceptable: API key is not provided.
- 429 Too Many Requests: API key rate limit reached.
GET /v1/campaigns/{id}
- Description: Retrieve specific campaign details.
- Parameters:
- id (required): Unique ID of the campaign.
- Headers:
- x-api-key: API key generated for your account.
- Responses:
- 200 OK: Campaign details.
- 401 Unauthorized: Provided API key is not valid.
- 404 Not Found: Campaign with provided ID not found.
- 406 Not Acceptable: API key is not provided.
- 429 Too Many Requests: API key rate limit reached.
2.3.2 Export Leads
GET /v1/leads/
- Description: Export leads of all campaigns.
- Parameters:
- interval (optional): Predefined time frames (daily, weekly, monthly, yearly, custom).
- from (optional): Specific time frame start date.
- to (optional): Specific time frame end date.
- page (optional): Pagination index (default: 1).
- Headers:
- x-api-key: API key generated for your account.
- Responses:
- 200 OK: Exported leads.
- 400 Bad Request: Request is not valid.
- 401 Unauthorized: Provided API key is not valid.
- 406 Not Acceptable: API key is not provided.
- 429 Too Many Requests: API key rate limit reached.
2.3.3 Overall Account Details
GET /v1/account/
- Description: Retrieve overall account details.
- Headers:
- x-api-key: API key generated for your account.
- Responses:
- 200 OK: Overall account details.
- 401 Unauthorized: Provided API key is not valid.
- 406 Not Acceptable: API key is not provided.
- 429 Too Many Requests: API key rate limit reached.
2.3.4 Overall Report
GET /v1/report/
- Description: Retrieve overall campaign report.
- Parameters:
- groupBy (optional): Grouping date parameter (daily, weekly, monthly, yearly).
- from (optional): Specific time frame start date.
- to (optional): Specific time frame end date.
- Headers:
- x-api-key: API key generated for your account.
- Responses:
- 200 OK: Overall campaign report.
- 400 Bad Request: Request is not valid.
- 401 Unauthorized: Provided API key is not valid.
- 406 Not Acceptable: API key is not provided.
- 429 Too Many Requests: API key rate limit reached.
GET /v1/report/{campaignId}
- Description: Retrieve specific campaign report.
- Parameters:
- groupBy (optional): Grouping date parameter (daily, weekly, monthly, yearly).
- from (optional): Specific time frame start date.
- to (optional): Specific time frame end date.
- campaignId (required): Unique ID of the campaign.
- Headers:
- x-api-key: API key generated for your account.
- Responses:
- 200 OK: Specific campaign report.
- 400 Bad Request: Request is not valid.
- 401 Unauthorized: Provided API key is not valid.
- 404 Not Found: Campaign with provided ID not found.
- 406 Not Acceptable: API key is not provided.
- 429 Too Many Requests: API key rate limit reached.
2.4 Example API Calls
PHP Curl
<?php
// Optimonk API endpoint
$api_url = 'https://api.optimonk.com/v1/campaigns/';
// API key
$api_key = 'YOUR_API_KEY';
// Pagination index (optional)
$page = 1;
// Set up cURL
$ch = curl_init($api_url . '?page=' . $page);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['x-api-key: ' . $api_key]);
// Execute cURL session and get the response
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
} else {
// Decode the JSON response
$decoded_response = json_decode($response, true);
// Handle the response as needed
print_r($decoded_response);
}
// Close cURL session
curl_close($ch);
?>
JavaScript
// Optimonk API endpoint
const apiURL = 'https://api.optimonk.com/v1/campaigns/';
// API key
const apiKey = 'YOUR_API_KEY';
// Pagination index (optional)
const page = 1;
// Set up Fetch API request
fetch(`${apiURL}?page=${page}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey,
},
})
.then(response => {
// Check if the request was successful (status code 200)
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json(); // Parse the JSON response
})
.then(data => {
// Handle the response data as needed
console.log(data);
})
.catch(error => {
// Handle errors
console.error('Fetch error:', error.message);
});
You can access more information on testing and response examples by clicking on the following link: OptiMonk Public API Documentation
✉️ If you have any further inquiries or require assistance, please don't hesitate to contact us at support@optimonk.com. We're here to provide you with any help you may need 😊
Comments