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://api.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 attrgetter

from rtbhouse_sdk.client import BasicAuth, Client
from rtbhouse_sdk.schema import CountConvention, StatsGroupBy, StatsMetric
from tabulate import tabulate

from config import PASSWORD, USERNAME

if __name__ == "__main__":
    with Client(auth=BasicAuth(USERNAME, PASSWORD)) as api:
        advertisers = api.get_advertisers()
        day_to = date.today()
        day_from = day_to - timedelta(days=30)
        group_by = [StatsGroupBy.DAY]
        metrics = [
            StatsMetric.IMPS_COUNT,
            StatsMetric.CLICKS_COUNT,
            StatsMetric.CAMPAIGN_COST,
            StatsMetric.CONVERSIONS_COUNT,
            StatsMetric.CTR
        ]
        stats = api.get_rtb_stats(
            advertisers[0].hash,
            day_from,
            day_to,
            group_by,
            metrics,
            count_convention=CountConvention.ATTRIBUTED_POST_CLICK,
        )
    columns = group_by + metrics
    data_frame = [
        [getattr(row, c.name.lower()) for c in columns]
        for row in reversed(sorted(stats, key=attrgetter("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-14.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rtbhouse_sdk-14.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rtbhouse_sdk-14.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for rtbhouse_sdk-14.1.0.tar.gz
Algorithm Hash digest
SHA256 de007b8386bdb0f7a82153cfb230ac55baa2c34e53fe7ea80ca8e0e7981b52dc
MD5 6d125ed806e09be717c85edca4df3a40
BLAKE2b-256 60f3e7f40eaa563fb20fda861817509073c7f51c67b768220db7379dcc9aa4d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for rtbhouse_sdk-14.1.0.tar.gz:

Publisher: ci.yaml on rtbhouse-apps/rtbhouse-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rtbhouse_sdk-14.1.0-py3-none-any.whl.

File metadata

  • Download URL: rtbhouse_sdk-14.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for rtbhouse_sdk-14.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4cf89e44576fb07b3d636a0cdac671f9e0286a3d0ec1ed2827157fae226287a
MD5 1708f2c446a455a749527e9c886c1473
BLAKE2b-256 5c5c85958edb1b51a1da17260ac2c230e4f459a781159a6a2ab27f991b2c1975

See more details on using hashes here.

Provenance

The following attestation bundles were made for rtbhouse_sdk-14.1.0-py3-none-any.whl:

Publisher: ci.yaml on rtbhouse-apps/rtbhouse-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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