Skip to main content

Async API wrapper for Tonic.com Publisher API v3

Project description

Async API wrapper for TONIC.for Publishers Api V3

How to use this package?

Step #1 - Install Tonic API Client:

pip install TonicPublisherAPI

Step #2 - create Client instance and use one of methods

from TonicPublisherAPI import TonicAPIClient

# Important - you need to initialize TonicAPIClient() inside async function because of aiohttp session,
that created on __init__() and used for all class methods to speedup network requests.

client = TonicAPIClient(your_consumer_key, your_consumer_password)

# Get campaigns list
...
await client.get_campaigns_list()
...

# Create new campaign
...
await client.create_campaign(
    name="New Campaign Name",
    offer="Educational Toys PR",
    country="US",
    offer_id="Offer ID",
    imprint="yes or no",
)
...

This package use aiohttp library to make requests to the Tonic Publishers API, so you need to use asynchronous programming style to create your business logic.

Example #1

import asyncio
from TonicPublisherAPI import TonicAPIClient

async def main():
    # Important - you need to initialize TonicAPIClient() inside async function
    # because of aiohttp session, that created on __init__() and used for all methods

    client = TonicAPIClient(your_consumer_key, your_consumer_password)
    
    campaigns = await client.get_campaigns_list(state="stopped", output="json") # Default state is "active"
    print(campaigns)
    
    # Important - you need to close session after all manipulations
    await client.close_session()

if __name__ == "__main__":
    asyncio.run(main())

Example #1 Output

[
  {
    "id": "1",
    "name": "First Campaign Test",
    "type": "display",
    "country": "US",
    "imprint": "no",
    "offer_id": "3",
    "offer": "Test Offer",
    "vertical": "Test Vertical",
    "link": "123456.track.com",
    "target": "test-target.bond"
  },
  {
    "id": "2",
    "name": "Second Campaign Test",
    "type": "display",
    "country": "US",
    "imprint": "no",
    "offer_id": "3",
    "offer": "Test Offer",
    "vertical": "Test Vertical",
    "link": "78901.track.com",
    "target": "test-target-2.bond"
  }
]

Project details


Release history Release notifications | RSS feed

This version

0.2

Download files

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

Source Distribution

TonicPublisherAPI-0.2.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

TonicPublisherAPI-0.2-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file TonicPublisherAPI-0.2.tar.gz.

File metadata

  • Download URL: TonicPublisherAPI-0.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for TonicPublisherAPI-0.2.tar.gz
Algorithm Hash digest
SHA256 901efae017d7e199edc1495f656a7602d14d38074c8b1a4acf39c827ea76658d
MD5 490c93997af5898f05074dd985f9b4bd
BLAKE2b-256 40393d3217e33a56e9c5f25a248bc0d02687c3868ca14e1be3cca3732c2f8998

See more details on using hashes here.

File details

Details for the file TonicPublisherAPI-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for TonicPublisherAPI-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 834b57fff79dfb1f13242e3562e262d51d49afee5d01c4d26f3b2bedb021e5ae
MD5 fd5c5b7dbf53036fb13931bbb933ec0b
BLAKE2b-256 1bb07cddb29193758aa50b5b0d8f2af58ca44fb64f74f71a9947a803ae172516

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