A modern Python client for the Apple Search Ads API with full type safety and async support
Project description
ASA API Client
A modern, fully-typed Python client for the Apple Search Ads API with async support and Pydantic models.
Features
- Full Type Safety - Complete type hints with strict mypy compliance
- Async Support - Both sync and async methods in a unified client
- Pydantic Models - Validated request/response models
- Resource-based API - Intuitive
client.campaigns.list()pattern - Automatic Pagination -
iter_all()anditer_all_async()helpers - Reports with Pandas - Optional DataFrame export
Installation
Using uv (recommended):
uv add asa-api-client
Using pip:
pip install asa-api-client
With pandas support:
uv add "asa-api-client[pandas]"
# or
pip install "asa-api-client[pandas]"
Quick Start
from asa_api_client import AppleSearchAdsClient
# From environment variables
client = AppleSearchAdsClient.from_env()
# Or explicit configuration
client = AppleSearchAdsClient(
client_id="SEARCHADS.xxx",
team_id="SEARCHADS.xxx",
key_id="xxx",
org_id=123456,
private_key_path="private-key.pem",
)
# List campaigns
with client:
campaigns = client.campaigns.list()
for campaign in campaigns:
print(f"{campaign.name}: {campaign.status}")
Environment Variables
export ASA_CLIENT_ID="SEARCHADS.your-client-id"
export ASA_TEAM_ID="SEARCHADS.your-team-id"
export ASA_KEY_ID="your-key-id"
export ASA_ORG_ID="123456"
export ASA_PRIVATE_KEY_PATH="/path/to/private-key.pem"
Or use a .env file:
ASA_CLIENT_ID=SEARCHADS.your-client-id
ASA_TEAM_ID=SEARCHADS.your-team-id
ASA_KEY_ID=your-key-id
ASA_ORG_ID=123456
ASA_PRIVATE_KEY_PATH=private-key.pem
Resources
Campaigns
# List all campaigns
campaigns = client.campaigns.list()
# Get a specific campaign
campaign = client.campaigns.get(campaign_id)
# Find with filters
from asa_api_client.models import Selector
enabled = client.campaigns.find(
Selector().where("status", "==", "ENABLED")
)
# Create a campaign
from asa_api_client.models import CampaignCreate, Money, CampaignSupplySource
campaign = client.campaigns.create(
CampaignCreate(
name="My Campaign",
adam_id=123456789,
countries_or_regions=["US"],
daily_budget_amount=Money(amount="100", currency="USD"),
supply_sources=[CampaignSupplySource.APPSTORE_SEARCH_RESULTS],
)
)
Ad Groups
# Access ad groups through campaign
ad_groups = client.campaigns(campaign_id).ad_groups.list()
# Create an ad group
from asa_api_client.models import AdGroupCreate
ad_group = client.campaigns(campaign_id).ad_groups.create(
AdGroupCreate(
name="My Ad Group",
default_bid_amount=Money(amount="1.00", currency="USD"),
)
)
Keywords
# List keywords in an ad group
keywords = client.campaigns(campaign_id).ad_groups(ad_group_id).keywords.list()
# Create keywords (bulk only)
from asa_api_client.models import KeywordCreate, KeywordMatchType
result = client.campaigns(campaign_id).ad_groups(ad_group_id).keywords.create_bulk([
KeywordCreate(
text="my keyword",
match_type=KeywordMatchType.EXACT,
bid_amount=Money(amount="1.50", currency="USD"),
)
])
Reports
from datetime import date
# Campaign report
report = client.reports.campaigns(
start_date=date(2024, 1, 1),
end_date=date(2024, 1, 31),
)
# Convert to DataFrame (requires pandas)
df = report.to_dataframe()
Async Usage
import asyncio
async def main():
client = AppleSearchAdsClient.from_env()
async with client:
campaigns = await client.campaigns.list_async()
# Async iteration
async for campaign in client.campaigns.iter_all_async():
print(campaign.name)
asyncio.run(main())
CLI
For a command-line interface, install asa-api-cli:
uv tool install asa-api-cli
# or
pip install asa-api-cli
License
MIT License - Copyright (c) 2025 Peth Pty Ltd
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asa_api_client-0.1.5.tar.gz.
File metadata
- Download URL: asa_api_client-0.1.5.tar.gz
- Upload date:
- Size: 102.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f85a6dc4b7052b95f599df0ff0f3d97a9de905167fe8e55cfb283f8a2d1b0386
|
|
| MD5 |
ae03f4baa7f8271fd6ccf29141ef64ac
|
|
| BLAKE2b-256 |
92ca93d20807de5db2c974a425b79d31d5e6aacbf02fdcb5b627bb7d0f79b856
|
Provenance
The following attestation bundles were made for asa_api_client-0.1.5.tar.gz:
Publisher:
publish.yml on SamPetherbridge/asa-api-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asa_api_client-0.1.5.tar.gz -
Subject digest:
f85a6dc4b7052b95f599df0ff0f3d97a9de905167fe8e55cfb283f8a2d1b0386 - Sigstore transparency entry: 759986906
- Sigstore integration time:
-
Permalink:
SamPetherbridge/asa-api-client@7c21b7a7f188759cd1894b8df3153c8a93f94134 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/SamPetherbridge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7c21b7a7f188759cd1894b8df3153c8a93f94134 -
Trigger Event:
release
-
Statement type:
File details
Details for the file asa_api_client-0.1.5-py3-none-any.whl.
File metadata
- Download URL: asa_api_client-0.1.5-py3-none-any.whl
- Upload date:
- Size: 48.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7fc8831469227fc7f72c8de0c4335c0a1255d85a93c8e9581778933f1ee7488
|
|
| MD5 |
656833030a78fc720ccebc1f6a887772
|
|
| BLAKE2b-256 |
b31c9d3936709aa22acb64ac64ed881ea264968cf8f19f5586badeb4914bda90
|
Provenance
The following attestation bundles were made for asa_api_client-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on SamPetherbridge/asa-api-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asa_api_client-0.1.5-py3-none-any.whl -
Subject digest:
d7fc8831469227fc7f72c8de0c4335c0a1255d85a93c8e9581778933f1ee7488 - Sigstore transparency entry: 759986914
- Sigstore integration time:
-
Permalink:
SamPetherbridge/asa-api-client@7c21b7a7f188759cd1894b8df3153c8a93f94134 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/SamPetherbridge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7c21b7a7f188759cd1894b8df3153c8a93f94134 -
Trigger Event:
release
-
Statement type: