Skip to main content

Python SDK for the PolyBridge public API.

Project description

PolyBridge Python SDK

Python SDK for the stable PolyBridge public API.

v0.1 scope is intentionally small: Search, Forecast, and Health only. It does not include Markets, Situation Room, streaming Forecast, MCP, pandas helpers, or analytics/timeseries utilities.

Installation

After release:

pip install polybridge

From a local checkout:

python -m pip install -e .

Anonymous Search

Search can be used without an API key.

from polybridge import PolyBridge

client = PolyBridge()

response = client.search(
    "US recession risk",
    top_k_per_dimension=3,
    filters={"status": "active"},
)

for result in response.results.get("direct", []):
    print(result.question, result.platform_url)

API-Key Search

When an API key is configured, the SDK sends it as Authorization: Bearer <api_key>.

from polybridge import PolyBridge

client = PolyBridge(api_key="YOUR_POLYBRIDGE_API_KEY")

response = client.search(
    "US recession risk",
    top_k_per_dimension=3,
    filters={"status": "active"},
)

You can also use the POLYBRIDGE_API_KEY environment variable.

export POLYBRIDGE_API_KEY="YOUR_POLYBRIDGE_API_KEY"
from polybridge import PolyBridge

client = PolyBridge()
client.health()

Forecast

Forecast requires an API key. If no key is configured, the SDK raises a local AuthenticationError before making a network request.

from polybridge import PolyBridge

client = PolyBridge(api_key="YOUR_POLYBRIDGE_API_KEY")

forecast = client.forecast(
    "Will there be a US recession in 2026?",
    include_graph=True,
)

print(forecast.probability)
print(forecast.reasoning)

Raw Responses

Use with_raw_response when you need HTTP metadata such as response headers or the raw body.

from polybridge import PolyBridge

client = PolyBridge(api_key="YOUR_POLYBRIDGE_API_KEY")

raw = client.with_raw_response.forecast("Will the Fed cut rates?")
print(raw.status_code, raw.request_id)
print(raw.parsed.probability)

Configuration

from polybridge import PolyBridge

client = PolyBridge(
    api_key="YOUR_POLYBRIDGE_API_KEY",
    base_url="https://api.polybridge.ai",
    timeout=10.0,
    forecast_timeout=120.0,
    attribution_code="partner-code",
    referrer="https://example.com",
)

Attribution headers are only sent when values are provided.

Errors And Rate Limits

All SDK exceptions inherit from PolyBridgeError.

from polybridge import PolyBridge, RateLimitError

client = PolyBridge(api_key="YOUR_POLYBRIDGE_API_KEY")

try:
    client.forecast("Will the Fed cut rates?")
except RateLimitError as error:
    print(error.status_code)
    print(error.request_id)
    print(error.retry_after)

Status errors expose status_code, detail, request_id, response_headers, raw_body, and for rate limits, retry_after.

Security

Do not expose long-lived PolyBridge API keys in browser or mobile clients. Route requests through a trusted backend you control.

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

polybridge-0.1.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polybridge-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file polybridge-0.1.0.tar.gz.

File metadata

  • Download URL: polybridge-0.1.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for polybridge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a8ff9ba9b98bf31971786846d39d8c91f17fe05b683900c5ed4f4c39e69fb5b7
MD5 8ba023bca0dd6bd4d66314112cb2b8d8
BLAKE2b-256 52e91f760495e6bc87227b1ba43143d2a0e6dcc2e2713330d48f230d9e40df34

See more details on using hashes here.

Provenance

The following attestation bundles were made for polybridge-0.1.0.tar.gz:

Publisher: publish.yml on crowdvector/polybridge-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polybridge-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: polybridge-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for polybridge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06aa8165c0e6b7484a23525122771906592dc2fef19da5ed3e54981c268a0b2d
MD5 b3f4ed30eaf6c11edbd6f16a69cb4c1a
BLAKE2b-256 a8b4c511a982a66c5c3dde2df61775f8be2f726908d8e99b90c3ec98b51cd12e

See more details on using hashes here.

Provenance

The following attestation bundles were made for polybridge-0.1.0-py3-none-any.whl:

Publisher: publish.yml on crowdvector/polybridge-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page