Skip to content

Commit c3e50fe

Browse files
📝 Add MkDocs documentation with GitHub Pages deployment
1 parent 2bff042 commit c3e50fe

14 files changed

Lines changed: 903 additions & 0 deletions

File tree

.github/workflows/docs.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v4
25+
with:
26+
version: "latest"
27+
28+
- name: Set up Python
29+
run: uv python install 3.13
30+
31+
- name: Install dependencies
32+
run: uv sync --extra docs
33+
34+
- name: Build documentation
35+
run: uv run mkdocs build
36+
37+
- name: Setup Pages
38+
uses: actions/configure-pages@v4
39+
40+
- name: Upload artifact
41+
uses: actions/upload-pages-artifact@v3
42+
with:
43+
path: site
44+
45+
deploy:
46+
environment:
47+
name: github-pages
48+
url: ${{ steps.deployment.outputs.page_url }}
49+
runs-on: ubuntu-latest
50+
needs: build
51+
steps:
52+
- name: Deploy to GitHub Pages
53+
id: deployment
54+
uses: actions/deploy-pages@v4

docs/api/client.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Client Reference
2+
3+
::: search_ads_api.AppleSearchAdsClient
4+
options:
5+
show_root_heading: true
6+
show_source: false
7+
members:
8+
- from_env
9+
- campaigns
10+
- reports

docs/api/exceptions.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Exceptions Reference
2+
3+
## Exception Hierarchy
4+
5+
```
6+
AppleSearchAdsError
7+
├── AuthenticationError
8+
├── ConfigurationError
9+
├── NotFoundError
10+
├── RateLimitError
11+
└── ValidationError
12+
```
13+
14+
## AppleSearchAdsError
15+
16+
Base exception for all API errors.
17+
18+
```python
19+
from search_ads_api import AppleSearchAdsError
20+
21+
try:
22+
client.campaigns.list()
23+
except AppleSearchAdsError as e:
24+
print(f"API error: {e}")
25+
```
26+
27+
## AuthenticationError
28+
29+
Raised when authentication fails.
30+
31+
```python
32+
from search_ads_api import AuthenticationError
33+
34+
try:
35+
client.campaigns.list()
36+
except AuthenticationError:
37+
print("Invalid credentials or expired token")
38+
```
39+
40+
## ConfigurationError
41+
42+
Raised when client configuration is invalid.
43+
44+
```python
45+
from search_ads_api import ConfigurationError
46+
47+
try:
48+
client = AppleSearchAdsClient(...)
49+
except ConfigurationError as e:
50+
print(f"Configuration error: {e}")
51+
```
52+
53+
## NotFoundError
54+
55+
Raised when a resource is not found.
56+
57+
```python
58+
from search_ads_api import NotFoundError
59+
60+
try:
61+
campaign = client.campaigns.get(123)
62+
except NotFoundError:
63+
print("Campaign not found")
64+
```
65+
66+
## RateLimitError
67+
68+
Raised when API rate limit is exceeded.
69+
70+
```python
71+
from search_ads_api import RateLimitError
72+
73+
try:
74+
client.campaigns.list()
75+
except RateLimitError as e:
76+
print(f"Rate limited, retry after: {e.retry_after}")
77+
```
78+
79+
## ValidationError
80+
81+
Raised when request validation fails.
82+
83+
```python
84+
from search_ads_api import ValidationError
85+
86+
try:
87+
client.campaigns.create(invalid_data)
88+
except ValidationError as e:
89+
print(f"Validation error: {e}")
90+
```

docs/api/models.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Models Reference
2+
3+
## Campaigns
4+
5+
::: search_ads_api.models.Campaign
6+
options:
7+
show_root_heading: true
8+
show_source: false
9+
10+
::: search_ads_api.models.CampaignCreate
11+
options:
12+
show_root_heading: true
13+
show_source: false
14+
15+
::: search_ads_api.models.CampaignUpdate
16+
options:
17+
show_root_heading: true
18+
show_source: false
19+
20+
## Ad Groups
21+
22+
::: search_ads_api.models.AdGroup
23+
options:
24+
show_root_heading: true
25+
show_source: false
26+
27+
::: search_ads_api.models.AdGroupCreate
28+
options:
29+
show_root_heading: true
30+
show_source: false
31+
32+
## Keywords
33+
34+
::: search_ads_api.models.Keyword
35+
options:
36+
show_root_heading: true
37+
show_source: false
38+
39+
::: search_ads_api.models.KeywordCreate
40+
options:
41+
show_root_heading: true
42+
show_source: false
43+
44+
## Common
45+
46+
::: search_ads_api.models.Money
47+
options:
48+
show_root_heading: true
49+
show_source: false
50+
51+
::: search_ads_api.models.Selector
52+
options:
53+
show_root_heading: true
54+
show_source: false
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Authentication
2+
3+
The Apple Search Ads API uses OAuth 2.0 with JWT tokens signed using ES256 (ECDSA).
4+
5+
## Getting API Credentials
6+
7+
1. Go to [Apple Search Ads](https://searchads.apple.com)
8+
2. Navigate to **Settings** > **API**
9+
3. Create a new API key
10+
4. Download your private key (`.pem` file)
11+
5. Note your Client ID, Team ID, and Key ID
12+
13+
## Configuration
14+
15+
### Environment Variables
16+
17+
Set the following environment variables:
18+
19+
```bash
20+
export ASA_CLIENT_ID="SEARCHADS.your-client-id"
21+
export ASA_TEAM_ID="SEARCHADS.your-team-id"
22+
export ASA_KEY_ID="your-key-id"
23+
export ASA_ORG_ID="123456"
24+
export ASA_PRIVATE_KEY_PATH="/path/to/private-key.pem"
25+
```
26+
27+
### Using a .env File
28+
29+
Create a `.env` file in your project:
30+
31+
```bash
32+
ASA_CLIENT_ID=SEARCHADS.your-client-id
33+
ASA_TEAM_ID=SEARCHADS.your-team-id
34+
ASA_KEY_ID=your-key-id
35+
ASA_ORG_ID=123456
36+
ASA_PRIVATE_KEY_PATH=private-key.pem
37+
```
38+
39+
### Direct Configuration
40+
41+
You can also pass credentials directly:
42+
43+
```python
44+
from search_ads_api import AppleSearchAdsClient
45+
46+
client = AppleSearchAdsClient(
47+
client_id="SEARCHADS.xxx",
48+
team_id="SEARCHADS.xxx",
49+
key_id="xxx",
50+
org_id=123456,
51+
private_key_path="private-key.pem",
52+
)
53+
```
54+
55+
Or with the private key content:
56+
57+
```python
58+
client = AppleSearchAdsClient(
59+
client_id="SEARCHADS.xxx",
60+
team_id="SEARCHADS.xxx",
61+
key_id="xxx",
62+
org_id=123456,
63+
private_key="-----BEGIN EC PRIVATE KEY-----\n...",
64+
)
65+
```
66+
67+
## Token Management
68+
69+
The client automatically handles:
70+
71+
- JWT creation and signing
72+
- Token refresh when expired
73+
- Request authentication headers
74+
75+
You don't need to manage tokens manually.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Installation
2+
3+
## Using uv (Recommended)
4+
5+
[uv](https://docs.astral.sh/uv/) is a fast Python package manager:
6+
7+
```bash
8+
uv add search-ads-api
9+
```
10+
11+
With pandas support for DataFrame exports:
12+
13+
```bash
14+
uv add "search-ads-api[pandas]"
15+
```
16+
17+
## Using pip
18+
19+
```bash
20+
pip install search-ads-api
21+
```
22+
23+
With pandas support:
24+
25+
```bash
26+
pip install "search-ads-api[pandas]"
27+
```
28+
29+
## Requirements
30+
31+
- Python 3.13+
32+
- Valid Apple Search Ads API credentials
33+
34+
## Dependencies
35+
36+
The package has minimal dependencies:
37+
38+
- `httpx` - HTTP client with async support
39+
- `pydantic` - Data validation
40+
- `pydantic-settings` - Settings management
41+
- `pyjwt[crypto]` - JWT authentication
42+
43+
Optional:
44+
45+
- `pandas` - DataFrame export support

0 commit comments

Comments
 (0)