Skip to main content

Windsor.ai Python SDK

A powerful, lightweight Python client and command-line interface (CLI) for the Windsor.ai API.

Easily fetch marketing data from Facebook, Google Ads, LinkedIn, and dozens of other platforms, unify it, and stream it directly into your Python scripts or data pipelines.

Features

  • Easy-to-use Client: Simple Python wrapper for API endpoints.
  • Built-in CLI: Query data directly from your terminal—perfect for cron jobs or quick checks.
  • Smart Filtering: Helper classes to construct complex API filters easily.
  • Data Streaming: Efficiently handle massive datasets with pagination automagically handled via generators.
  • Type Hints: Fully typed for better developer experience in modern IDEs.

Installation

Install the package via pip:

pip install windsor-ai

Authentication

You need a Windsor.ai API key. You can pass it explicitly to the client or set it as an environment variable (recommended).

Environment Variable:

export WINDSOR_API_KEY="your_api_key_here"

Python Library Usage

1. Basic Data Fetching

from windsor_ai import Client

# Initialize (automatically reads WINDSOR_API_KEY env var)
client = Client(api_key="your_api_key") 

# Fetch data
response = client.connectors(
    connector="facebook",
    date_preset="last_7d",
    fields=["date", "campaign", "clicks", "spend", "impressions"]
)

for row in response['data']:
    print(f"{row['date']}: {row['campaign']} - ${row['spend']}")

2. Advanced Filtering

Use the Filter class to create readable, robust queries.

from windsor_ai import Client, Filter

client = Client("your_api_key")

# Define filters
filters = [
    Filter("clicks", "gt", 100),            # Clicks greater than 100
    Filter("campaign", "contains", "Q4"),   # Campaign name contains "Q4"
]

data = client.connectors(
    connector="google_ads",
    date_preset="last_30d",
    fields=["campaign", "clicks", "cpc"],
    filters=filters
)

3. Handling Large Datasets (Streaming)

If you are exporting millions of rows, use stream_connectors. It yields records one by one, handling pagination behind the scenes so you don't run out of RAM.

client = Client("your_api_key")

# Returns a generator, not a list
iterator = client.stream_connectors(
    connector="all",
    date_preset="last_year",
    fields=["source", "campaign", "clicks", "spend"]
)

for row in iterator:
    # Process row immediately (e.g., write to CSV or Database)
    save_to_db(row)

CLI Usage

This package installs a command-line tool named windsor.

1. List Available Connectors

windsor list-connectors

2. Check Available Fields

See which metrics and dimensions are available for a specific platform.

windsor fields facebook

3. Query Data

Fetch data and output as JSON (default) or CSV.

# Fetch last 7 days of Facebook data
windsor query \
  --connector facebook \
  --date-preset last_7d \
  --fields date,campaign,clicks,spend \
  --format json

4. CLI Filtering and Exporting

You can filter data using the field:operator:value syntax.

Operators: eq, neq, gt, gte, lt, lte, contains, ncontains, null, notnull.

# Export Google Ads data to a CSV file
windsor query \
  --connector google_ads \
  --date-preset last_30d \
  --fields campaign,clicks,impressions \
  --filter "clicks:gt:50" \
  --filter "campaign:contains:Summer" \
  --format csv \
  --out report.csv

Development

To contribute to this project:

  1. Clone the repository.
  2. Install dependencies and the package in editable mode:
    pip install -e .
    pip install build twine pytest flake8
    
  3. Run tests:
    # Requires WINDSOR_API_KEY to be set
    pytest
    

License

This project is licensed under the MIT License.

Metadata

Release files for windsor-ai 0.2.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 windsor-ai 0.2.0
File Size Uploaded Provenance Actions
windsor_ai-0.2.0.tar.gz 11.7 kB Without provenance Details for windsor_ai-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for windsor-ai 0.2.0
File Interpreter ABI Platform Actions
windsor_ai-0.2.0-py3-none-any.whl Python 3 none any Details for windsor_ai-0.2.0-py3-none-any.whl

Total release size: 21.8 kB

Release files / windsor_ai-0.2.0.tar.gz

Download URL windsor_ai-0.2.0.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9fc1f9a0ff67e899c1746ebadb2ab30f993cdc1c5590a5a4c1bd2086c236ac3b
BLAKE2b-256 checksum
How to use checksums
02e15ec3e5a87b84bdddbb71ce2c35ea418c613704ccd3d52851dee6e2c16738
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / windsor_ai-0.2.0-py3-none-any.whl

Download URL windsor_ai-0.2.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2dcf990e09a1f6fb876bba0c9924abe1a7467c3a277d32ae523017a23df5be0e
BLAKE2b-256 checksum
How to use checksums
35fec38d95cac74e04e6647c41502d23e5e9876f77c467dc5fbbdbf8c098567d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for windsor-ai 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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