Statystyki kampanii
curl --request GET \
--url https://api.example.com/api/v1/campaigns/{id}/statisticsimport requests
url = "https://api.example.com/api/v1/campaigns/{id}/statistics"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/campaigns/{id}/statistics', 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.example.com/api/v1/campaigns/{id}/statistics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$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.example.com/api/v1/campaigns/{id}/statistics"
req, _ := http.NewRequest("GET", url, nil)
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.example.com/api/v1/campaigns/{id}/statistics")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/campaigns/{id}/statistics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"sent": 10000,
"delivered": 9800,
"opened": 4500,
"clicked": 1200,
"bounced": 200,
"complained": 5,
"unsubscribed": 15,
"open_rate": 45.92,
"click_rate": 12.24,
"bounce_rate": 2.04,
"click_to_open_rate": 26.67,
"unsubscribe_rate": 0.15
}
}
{
"success": false,
"error": {
"code": "CAMPAIGN_NOT_FOUND",
"message": "Nie znaleziono kampanii o ID: 456"
}
}
{
"success": false,
"error": {
"code": "PERMISSION_DENIED",
"message": "Klucz API nie posiada uprawnienia 'campaigns.read'"
}
}
Kampanie
Statystyki kampanii
Pobierz szczegółowe metryki wydajności i analizy kampanii
GET
/
api
/
v1
/
campaigns
/
{id}
/
statistics
Statystyki kampanii
curl --request GET \
--url https://api.example.com/api/v1/campaigns/{id}/statisticsimport requests
url = "https://api.example.com/api/v1/campaigns/{id}/statistics"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/campaigns/{id}/statistics', 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.example.com/api/v1/campaigns/{id}/statistics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$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.example.com/api/v1/campaigns/{id}/statistics"
req, _ := http.NewRequest("GET", url, nil)
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.example.com/api/v1/campaigns/{id}/statistics")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/campaigns/{id}/statistics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"sent": 10000,
"delivered": 9800,
"opened": 4500,
"clicked": 1200,
"bounced": 200,
"complained": 5,
"unsubscribed": 15,
"open_rate": 45.92,
"click_rate": 12.24,
"bounce_rate": 2.04,
"click_to_open_rate": 26.67,
"unsubscribe_rate": 0.15
}
}
{
"success": false,
"error": {
"code": "CAMPAIGN_NOT_FOUND",
"message": "Nie znaleziono kampanii o ID: 456"
}
}
{
"success": false,
"error": {
"code": "PERMISSION_DENIED",
"message": "Klucz API nie posiada uprawnienia 'campaigns.read'"
}
}
Parametry ścieżki
integer
required
ID kampanii
Odpowiedź
boolean
Wskazuje czy żądanie zakończyło się sukcesem
object
Obiekt statystyk kampanii
Show Pola statystyk
Show Pola statystyk
integer
Całkowita liczba wysłanych wiadomości
integer
Pomyślnie dostarczone wiadomości (sent - bounced)
integer
Otwarte wiadomości (unikalne otwarcia)
integer
Kliknięte linki (unikalne kliknięcia)
integer
Odrzucone wiadomości
integer
Zgłoszenia spam
integer
Wypisania wywołane przez tę kampanię
number
Współczynnik otwarć w procentach (opened / delivered * 100)
number
Współczynnik kliknięć w procentach (clicked / delivered * 100)
number
Współczynnik odrzuceń w procentach (bounced / sent * 100)
number
Współczynnik kliknięć do otwarć w procentach (clicked / opened * 100)
number
Współczynnik wypisań w procentach (unsubscribed / delivered * 100)
Przykład
curl https://api.mailist.com/api/v1/campaigns/456/statistics \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://api.mailist.com/api/v1/campaigns/456/statistics', {
headers: {
'X-API-Key': 'YOUR_API_KEY'
}
});
const data = await response.json();
import requests
response = requests.get(
'https://api.mailist.com/api/v1/campaigns/456/statistics',
headers={'X-API-Key': 'YOUR_API_KEY'}
)
data = response.json()
Odpowiedź
{
"success": true,
"data": {
"sent": 10000,
"delivered": 9800,
"opened": 4500,
"clicked": 1200,
"bounced": 200,
"complained": 5,
"unsubscribed": 15,
"open_rate": 45.92,
"click_rate": 12.24,
"bounce_rate": 2.04,
"click_to_open_rate": 26.67,
"unsubscribe_rate": 0.15
}
}
{
"success": false,
"error": {
"code": "CAMPAIGN_NOT_FOUND",
"message": "Nie znaleziono kampanii o ID: 456"
}
}
{
"success": false,
"error": {
"code": "PERMISSION_DENIED",
"message": "Klucz API nie posiada uprawnienia 'campaigns.read'"
}
}
Uwagi
- Statystyki są obliczane w czasie rzeczywistym na podstawie odbiorców kampanii
- Współczynniki są zaokrąglane do 2 miejsc po przecinku
- Ten endpoint wymaga uprawnienia
campaigns.readdla klucza API - Statystyki są dostępne tylko dla kampanii ze statusem
SENT
