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
Project details
Release history Release notifications | RSS feed
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-13.0.0.tar.gz
(10.1 kB
view details)
Built Distribution
File details
Details for the file rtbhouse_sdk-13.0.0.tar.gz
.
File metadata
- Download URL: rtbhouse_sdk-13.0.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85291238729c25f5de1357d04f873054104e8c7a9b077d0ea57f90eff5a71515 |
|
MD5 | 0a922864f713174eddae275fafb267fa |
|
BLAKE2b-256 | 088e58a0bfc1d0df9181ede106d065cf5c5188bf917c95ec0ff9be9afa79fbfa |
File details
Details for the file rtbhouse_sdk-13.0.0-py3-none-any.whl
.
File metadata
- Download URL: rtbhouse_sdk-13.0.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27cdc1c766ceb8ab3cad7bc2fe43d14f92cf75bf3919e9038ab03f973bda6d02 |
|
MD5 | 72747d5b2ac67303398ec9e7914801c0 |
|
BLAKE2b-256 | 04a9f2b82ca8993aa2d5fc7aad5a51a13e7c391e82cd2e037e5b125227540e02 |