Skip to main content

RTB House SDK

Project description

Overview

This library provides an easy-to-use Python interface to RTB House API. It allows you to read and manage you campaigns settings, browse offers, download statistics etc.

API docs: https://panel.rtbhouse.com/api/docs

Installation

RTB House SDK can be installed with pip:

$ pip install rtbhouse_sdk

Usage example

Let’s write a script which fetches campaign stats (imps, clicks, postclicks) and shows the result as a table (using tabulate library).

First, create config.py file with your credentials:

USERNAME = 'jdoe'
PASSWORD = 'abcd1234'

Set up virtualenv and install requirements:

$ pip install rtbhouse_sdk tabulate
from datetime import date, timedelta
from operator import itemgetter

from rtbhouse_sdk.reports_api import Conversions, ReportsApiSession
from tabulate import tabulate

from config import PASSWORD, USERNAME

if __name__ == "__main__":
    api = ReportsApiSession(USERNAME, PASSWORD)
    advertisers = api.get_advertisers()
    day_to = date.today()
    day_from = day_to - timedelta(days=30)
    group_by = ["day"]
    metrics = ["impsCount", "clicksCount", "campaignCost", "conversionsCount", "ctr"]
    stats = api.get_rtb_stats(
        advertisers[0]["hash"],
        day_from,
        day_to,
        group_by,
        metrics,
        count_convention=Conversions.ATTRIBUTED_POST_CLICK,
    )
    columns = group_by + metrics
    data_frame = [
        [row[c] for c in columns]
        for row in reversed(sorted(stats, key=itemgetter("day")))
    ]
    print(tabulate(data_frame, headers=columns))

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rtbhouse_sdk-7.0.0.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file rtbhouse_sdk-7.0.0.tar.gz.

File metadata

  • Download URL: rtbhouse_sdk-7.0.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.7

File hashes

Hashes for rtbhouse_sdk-7.0.0.tar.gz
Algorithm Hash digest
SHA256 983fe869ee5722d58a99d5db5dd0e8b4845615b78b5661582859063fd62f1f8c
MD5 4c4d25304b51530c7202f6d76cc7e834
BLAKE2b-256 6da4fcfb0a7e57a99e854b625703a4d83da4d74da7432a732b84101a0f2d46e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page