TikTok Business API SDK
raw JSON → 1.1.3 verified Fri May 01 auth: no python
Official TikTok Business API SDK for Python, version 1.1.3. Provides classes and methods to interact with TikTok's advertising platform (Business API). Released as needed; currently stable.
pip install tiktok-business-api-sdk-official Common errors
error ModuleNotFoundError: No module named 'tiktok_business_sdk' ↓
cause Old import path used; SDK renamed in v1.1.0.
fix
Use 'from tiktok_business_api_sdk import TikTokBusinessApiClient' instead.
error AttributeError: 'TikTokBusinessApiClient' object has no attribute 'get_advertiser' ↓
cause Deprecated method removed in v1.1.0.
fix
Use client.get('/open_api/v1.2/advertiser/info/', params={'advertiser_id': id})
error requests.exceptions.HTTPError: 401 Client Error: Unauthorized ↓
cause Access token missing or expired.
fix
Ensure access_token is provided and valid. Regenerate if necessary.
Warnings
breaking SDK v1.1.x changed the import path from 'tiktok_business_sdk' to 'tiktok_business_api_sdk'. Old imports will raise ModuleNotFoundError. ↓
fix Update imports to use 'tiktok_business_api_sdk' instead of 'tiktok_business_sdk'.
gotcha Access token is required; the SDK does not handle token refresh automatically. ↓
fix Implement token refresh logic externally or regenerate tokens via OAuth before expiry.
gotcha Base URL is hardcoded to 'https://business-api.tiktok.com'. For sandbox, you must override it. ↓
fix Pass 'base_url' parameter to client constructor: TikTokBusinessApiClient(..., base_url='https://sandbox-ads.tiktok.com')
deprecated The 'get_advertiser' method in v1.0 has been deprecated; use generic 'get' or 'post' instead. ↓
fix Replace client.get_advertiser(advertiser_id) with client.get('/open_api/v1.2/advertiser/info/', params={'advertiser_id': advertiser_id})
Imports
- TikTokBusinessApiClient
from tiktok_business_api_sdk import TikTokBusinessApiClient - AdGroup
from tiktok_business_api_sdk.models import AdGroup - Campaign
from tiktok_business_api_sdk.models import Campaign
Quickstart
from tiktok_business_api_sdk import TikTokBusinessApiClient
client = TikTokBusinessApiClient(
app_id=os.environ.get('TIKTOK_APP_ID', ''),
secret=os.environ.get('TIKTOK_SECRET', ''),
access_token=os.environ.get('TIKTOK_ACCESS_TOKEN', '')
)
# Example: list campaigns (adjust endpoint as needed)
campaigns = client.get('/open_api/v1.2/campaign/get/', params={'advertiser_id': 'YOUR_ADVERTISER_ID'})
print(campaigns)