Arcane bing
This package is based on msads, the Microsoft Advertising REST SDK.
Get Started
pip install arcane-bing
Example Usage
Reporting
bing_client = Client(
credentials=Config.BING_ADS_CREDENTIALS,
secrets_bucket=Config.SECRETS_BUCKET,
refresh_token_location=Config.BING_ADS_REFRESH_TOKEN,
storage_client=storage_client
)
reporting_service_manager, reporting_service = bing_client.get_bing_ads_api_client()
report_request = build_campaigns_report(bing_account_id)
result_file_path = bing_client.submit_and_download(report_request, reporting_service_manager)
Campaign Service
⚠️ For some API methods, you must provide the client's account id and the manager's customer id
from arcane.bing import Client, to_microsoft_advertising_exception
from openapi_client.exceptions import ApiException
from openapi_client.models.campaign import CampaignType, GetCampaignsByAccountIdRequest
bing_client = Client(
credentials=Config.BING_ADS_CREDENTIALS,
secrets_bucket=Config.SECRETS_BUCKET,
refresh_token_location=Config.BING_ADS_REFRESH_TOKEN,
storage_client=storage_client,
customer_id=CUSTOMER_ID,
account_id=ACCOUNT_ID
)
campaign_service = bing_client.get_service_client(service_name='CampaignManagement')
try:
# Ids are strings. Without campaign_type, only Search campaigns are returned.
request = GetCampaignsByAccountIdRequest(
AccountId=str(ACCOUNT_ID),
CampaignType=CampaignType.SEARCH | CampaignType.SHOPPING
)
response = campaign_service.get_campaigns_by_account_id(get_campaigns_by_account_id_request=request)
all_campaigns = response.campaigns or []
# do stuff with all_campaigns
except ApiException as e:
# Raises MicrosoftAdvertisingAccountLostAccessException, MicrosoftAdvertisingAuthenticationException,
# MicrosoftAdvertisingRateLimitException, MicrosoftAdvertisingServerException or MicrosoftAdvertisingApiException
raise to_microsoft_advertising_exception(e, ACCOUNT_ID) from e
Errors
Client methods calling Microsoft Advertising (get_bing_campaigns, get_account_name, submit_and_download)
convert API errors according to the Microsoft Advertising error code:
| Exception | Cause | Retried by the client |
|---|---|---|
MicrosoftAdvertisingAccountLostAccessException |
No access to the account, invalid account | No |
MicrosoftAdvertisingAuthenticationException |
Invalid or expired credentials | No |
MicrosoftAdvertisingRateLimitException |
Too many calls or report requests | Yes, after 60 seconds |
MicrosoftAdvertisingServerException |
Microsoft Advertising unavailable | Yes |
MicrosoftAdvertisingApiException |
Any other rejected request | No |
Network errors (timeouts, closed connections) keep their type and are retried.
Release files for arcane-bing 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| arcane_bing-1.0.2.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| arcane_bing-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.9 kB
Release files / arcane_bing-1.0.2.tar.gz
| Download URL | arcane_bing-1.0.2.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c6a33409c81947ce4527c6d0ff97aaaa7784477e2203aec4f845a0848f606db
|
|
BLAKE2b-256 checksum How to use checksums |
6dcdcb7fcebd76e1e46f7b2797f2c37a0e046905f726bfc500a1dff58eb1bf68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.12.14 Linux/6.17.0-1022-azure
|
Release files / arcane_bing-1.0.2-py3-none-any.whl
| Download URL | arcane_bing-1.0.2-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b4339a71d522b1d8bec9495f233070f73a9aa8344e4257a97fa07efbeca74a16
|
|
BLAKE2b-256 checksum How to use checksums |
8168f343d6f83870cb89e28b36f98e700ca92e059ab8e5d5d4c3582b073fc8ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.12.14 Linux/6.17.0-1022-azure
|