Python SDK
Python SDK
Synchronous Python client for server-side integrations. Install meridianads from GitLab PyPI.
Install
Point pip at the GitLab PyPI registry for this project, then install meridianads.
Python
# GitLab PyPI for yelle/saas/meridian-ads (private registry).
# GITLAB_TOKEN: a GitLab personal access token or deploy token with read_api or read_package_registry.
# --index-url (not --extra-index-url) so pip never resolves meridianads from public PyPI.
pip install meridianads \
--index-url "https://gitlab-ci-token:${GITLAB_TOKEN}@git.yelle.software/api/v4/projects/yelle%2Fsaas%2Fmeridian-ads/packages/pypi/simple"Serve, render, click
Call serve with a placement name and traits dict. Call impression after the ad is visible. Route users through click_url.
Python
import os
from meridianads import Client
client = Client(
app_key=os.environ["MERIDIAN_ADS_APP_KEY"],
secret=os.environ["MERIDIAN_ADS_SECRET"],
)
decision = client.serve("home", "user-42", {"country": "US", "plan": "pro"})
if decision is None:
pass # HTTP 204
else:
client.impression(decision)
href = decision.click_urlNext
Users and context and Targeting traits explain what to send on each serve call.