Official Python SDK for the First Forecast B2B2C API.
Project description
first-forecast
Official Python SDK for the First Forecast B2B2C API.
pip install first-forecast
Quick start (sync)
import os
from first_forecast import FirstForecast
ff = FirstForecast(api_key=os.environ["FF_API_KEY"]) # ff_live_... or ff_test_...
result = ff.forecast("AAPL", persona="balanced")
print(result["compliance"]["jurisdiction"]) # 'US'
print(result["forecast"]["horizons"][0]["most_probable"])
Quick start (async)
import asyncio
from first_forecast import AsyncFirstForecast
async def main():
async with AsyncFirstForecast(api_key=...) as ff:
result = await ff.forecast("AAPL", jurisdiction="EU")
print(result["compliance"]["rules_applied"])
asyncio.run(main())
Sandbox
ff = FirstForecast(
api_key=os.environ["FF_SANDBOX_KEY"], # ff_test_<...>
base_url="https://api-sandbox.first-forecast.app",
)
Methods
| Method | Endpoint |
|---|---|
ff.forecast(ticker, ...) |
GET /v1/forecast/{ticker} |
ff.multi(tickers, ...) |
GET /v1/multi |
ff.tickers(...) |
GET /v1/tickers |
ff.usage() |
GET /v1/usage |
The SSE stream endpoint (/v1/forecast/{ticker}/stream) is not
bundled — use httpx-sse
or aiohttp directly.
Errors
from first_forecast import FirstForecast, FirstForecastError
try:
ff.forecast("NOTAREAL")
except FirstForecastError as e:
if e.kind == "auth": # 401 / 403
...
elif e.kind == "not_found": # 404
...
elif e.kind == "bad_request":
...
elif e.kind == "rate_limited":
wait = e.retry_after or 5
...
elif e.kind == "server_error":
...
elif e.kind == "network": # httpx.HTTPError
...
elif e.kind == "parse": # server returned non-JSON
...
print(e.status, e.body)
Versioning
Tracks packages/schemas/openapi.yml in the
first-forecast monorepo.
Major-version bumps indicate a breaking change to that contract.
License
MIT.
Project details
Release history Release notifications | RSS feed
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 first_forecast-0.1.1.tar.gz.
File metadata
- Download URL: first_forecast-0.1.1.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e3603c451e1b5f1a04e5a6d71df7b9b1b6e7a67b9785acfcd5f42844b491bbc
|
|
| MD5 |
746841b944bce1daf4adf6f0661d300f
|
|
| BLAKE2b-256 |
2af0b6d35dfe2b32f7cc69ec5e67191bf5dbb8427d36c01dd47d112cfee5fad4
|
File details
Details for the file first_forecast-0.1.1-py3-none-any.whl.
File metadata
- Download URL: first_forecast-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
763412884d397c6820d4e92a650de34794084e3fde766baa41c20bfdd1eca4a4
|
|
| MD5 |
5b10a754f5e6035e83d11a66535f5707
|
|
| BLAKE2b-256 |
8cd60a151ea3f82abb7392b8fb3759f5ef84db85166d9d8cfa63f14b76b8da4a
|