Quick Help

The knowledgebase is a categorized collection of answers to frequently asked questions (FAQ) and articles. You can read articles in this category or select a subcategory that you are interested in.



 PixFuture Statistics API – Integration & Usage Guide

Solution

Pixfuture API User Manual

This document provides instructions for using the Pixfuture API to retrieve performance statistics. The API supports retrieving data for yesterday's stats and the previous week's stats using HTTP GET requests with basic authentication.

Table of Contents

  1. Overview
  2. Authentication
  3. API Endpoints
  4. Response Format
  5. Example Usage
  6. Error Handling
  7. Contact Support

Overview

The Pixfuture API allows publishers to retrieve performance statistics for their account. The API uses HTTP GET requests with basic authentication and returns data in JSON format. This manual covers two endpoints: one for retrieving yesterday's stats and another for the previous week's stats.

Authentication

The API uses basic HTTP authentication. You must include your username and password in each request.

  • Username: Your registered email address (e.g., publisheruser@domain.com)
  • Password: Your account password (e.g., 12345)
  • Header: Include -H "Accept: application/json" to specify that the response should be in JSON format.

Note: Ensure your credentials are kept secure and not shared publicly.

API Endpoints

Yesterday's Stats

Retrieve performance statistics for the previous day.

  • Endpoint: https://pub-api.pixfuture.com/api/yesterday-stats
  • Method: GET
  • Authentication: Basic (username:password)
  • Headers:
    • Accept: application/json

Example Request:

curl -u user123@domain.com:12345 -X GET https://pub-api.pixfuture.com/api/yesterday-stats \
-H "Accept: application/json"

Previous Week's Stats

Retrieve performance statistics for the previous week.

  • Endpoint: https://pub-api.pixfuture.com/api/previous-week-stats
  • Method: GET
  • Authentication: Basic (username:password)
  • Headers:
    • Accept: application/json

Example Request:

curl -u user123@domain.com:12345 -X GET https://pub-api.pixfuture.com/api/previous-week-stats \
-H "Accept: application/json"

Response Format

Both endpoints return data in JSON format. The response includes performance metrics for the specified period, such as account ID, site name, impressions, and revenue. Current time in UTC, with the week starting on Monday (ISO 8601 standard).

A typical response may look like:

{
  "data": [
    {
      "accountid": 10103,
      "sitename": "Your domain URL",
      "impressions": 199,
      "revenue": 0.024793952886284387
    },
    {
      "accountid": 10104,
      "sitename": "Your domain URL",
      "impressions": 333,
      "revenue": 0.53332886284387
    }
  ]
}
  • data: An array containing performance metrics for the account.
    • accountid: The unique identifier for the account (e.g., 10103).
    • sitename: The URL of the site associated with the stats (e.g., https://www.publisherdomain.com).
    • impressions: The number of ad impressions (e.g., 199).
    • revenue: The revenue generated (e.g., 0.024793952886284387).

For yesterday-stats, the data reflects metrics for a single day. For previous-week-stats, the data may represent aggregated metrics for the week or a breakdown by day, depending on the API configuration. Refer to Pixfuture's API documentation for additional fields or variations.

Example Usage

Using cURL

To retrieve yesterday's stats using curl:

curl -u user123@domain.com:12345 -X GET https://pub-api.pixfuture.com/api/yesterday-stats \
-H "Accept: application/json"

To retrieve previous week's stats using curl:

curl -u user123@domain.com:12345 -X GET https://pub-api.pixfuture.com/api/previous-week-stats \
-H "Accept: application/json"

Using Python

You can use the requests library in Python to make API calls:

import requests
from requests.auth import HTTPBasicAuth

# Yesterday's Stats
response = requests.get(
    "https://pub-api.pixfuture.com/api/yesterday-stats",
    auth=HTTPBasicAuth("user123@domain.com", "12345"),
    headers={"Accept": "application/json"}
)
print(response.json())

# Previous Week's Stats
response = requests.get(
    "https://pub-api.pixfuture.com/api/previous-week-stats",
    auth=HTTPBasicAuth("user123@domain.com", "12345"),
    headers={"Accept": "application/json"}
)
print(response.json())

Using PHP

You can use PHP's curl functions to make API calls:

<?php
$username = "user123@domain.com";
$password = "12345";

// Yesterday's Stats
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://pub-api.pixfuture.com/api/yesterday-stats");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json"));
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
print_r($data);

// Previous Week's Stats
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://pub-api.pixfuture.com/api/previous-week-stats");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json"));
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
print_r($data);
?>

Error Handling

Common errors include:

  • 401 Unauthorized: Invalid username or password.
    • Solution: Verify your credentials and ensure they are correctly formatted.
  • 400 Bad Request: Missing or incorrect headers.
    • Solution: Ensure the Accept: application/json header is included.
  • 429 Too Many Requests: Rate limit exceeded.
    • Solution: Wait before making additional requests or contact Pixfuture support for rate limit details.
  • 500 Internal Server Error: Server-side issue.
    • Solution: Retry the request or contact Pixfuture support.

Always check the status field in the response to confirm the request was successful.

Contact Support

For issues or further assistance, contact Pixfuture support at:

Article details

Article ID: 74

Category: Publishers