Skip to main content

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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arcane-bing 1.0.0
File Size Uploaded
arcane_bing-1.0.0.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for arcane-bing 1.0.0
File Interpreter ABI Platform
arcane_bing-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.3 kB

Release files / arcane_bing-1.0.0.tar.gz

Download URL arcane_bing-1.0.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5c2546ca2bae375b943e5312a832ad3e364dd4822d2088b3519d621b028ad5c9
BLAKE2b-256 checksum
How to use checksums
5cdd7b2220513d509b59ada38ef180825ecc254a9bda3deb34cb2d07803fd6a3
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.0-py3-none-any.whl

Download URL arcane_bing-1.0.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
09e09944dcd5cea0ddb0fed43d9f138601be35813a70da948189a4301f928819
BLAKE2b-256 checksum
How to use checksums
b6726dd675cd499459d180ca7673ef9c6d3836f8e2d771b5a65278acbd4cac6f
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 history Release notifications | RSS feed

1.0.2

2 release files

1.0.1

2 release files

This release

1.0.0 This release

2 release files

0.5.10

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page