title: futurenews Python API reference description: Full API reference for the futurenews library: clients, models and exceptions.
API reference¶
Clients¶
Public clients: :class:FutureNews (sync) and :class:AsyncFutureNews.
Made by Chipa dev team. Sign up to Future News: https://future.news/41L85FOV
AsyncFutureNews
¶
Asynchronous Future News client (same arguments and resources as :class:FutureNews).
Source code in src/futurenews/client.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
aclose()
async
¶
Close the underlying connection pool.
Source code in src/futurenews/client.py
135 136 137 | |
FutureNews
¶
Synchronous Future News client.
Resources: trending, rank, events, calendar, twitter
(public) and wallet, account (need auth_token).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth_token
|
str | None
|
Bearer access token for authenticated endpoints. Treat it
like a password. It is never logged and hidden from |
None
|
cookies
|
dict[str, str] | None
|
Optional browser cookies (e.g. |
None
|
headers
|
dict[str, str] | None
|
Extra/override headers. |
None
|
proxy
|
str | None
|
Proxy URL, e.g. |
None
|
timeout
|
float
|
Seconds. Default 30. |
30.0
|
device_id
|
str | None
|
Reuse a device id; random uuid4 by default. |
None
|
Source code in src/futurenews/client.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
close()
¶
Close the underlying connection pool.
Source code in src/futurenews/client.py
81 82 83 | |
Models¶
Pydantic models for the trending/list endpoint.
Response models are deliberately permissive (extra="allow"): Future News
can add fields at any time and we never want that to break your code.
ApiResponse
¶
Bases: BaseModel
Permissive wrapper for endpoints whose payload shape is not modelled yet.
data is the "data" field of the JSON object (or the whole payload
when there is no such field); raw is always the untouched payload.
Other top-level fields (code, msg...) are kept in model_extra (and as
attributes unless the name clashes with a pydantic method; use raw then).
Source code in src/futurenews/models.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
from_payload(payload)
classmethod
¶
Wrap any JSON payload.
Source code in src/futurenews/models.py
127 128 129 130 131 132 133 | |
RankRequest
¶
Bases: BaseModel
Body for POST /events/api/rank (the "new", "trending"... tabs).
Source code in src/futurenews/models.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
to_body()
¶
JSON body; optional fields are omitted when unset, like the web app.
Source code in src/futurenews/models.py
101 102 103 104 105 106 | |
TrendingItem
¶
Bases: BaseModel
One trending entry. Unknown fields are preserved.
Source code in src/futurenews/models.py
37 38 39 40 | |
TrendingRequest
¶
Bases: BaseModel
Body sent to POST /events/api/trending/list.
Unknown option names are rejected so typos (limt=5) fail loudly.
Source code in src/futurenews/models.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
to_body()
¶
Return the JSON body exactly as the Future News web app sends it.
Source code in src/futurenews/models.py
32 33 34 | |
TrendingResponse
¶
Bases: BaseModel
Parsed trending/list response.
Source code in src/futurenews/models.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
from_payload(payload)
classmethod
¶
Build from raw JSON, tolerating null/missing/odd shapes.
Entries are looked up under the well-known keys data, events,
items and list (recursing into nested envelopes such as
{"data": {"list": [...]}}). Any other list is NOT guessed at, so
an error body can never be mistaken for trending items. Remaining
top-level fields (code, msg, pagination...) are preserved.
Source code in src/futurenews/models.py
50 51 52 53 54 55 56 57 58 59 60 61 62 | |
iso_date(value, name)
¶
Return YYYY-MM-DD for a date or ISO string; ValueError otherwise.
Source code in src/futurenews/models.py
136 137 138 139 140 141 142 143 144 145 | |
Exceptions¶
Exception hierarchy for futurenews.
Catch :class:FutureNewsError to handle everything this library raises.
APIError
¶
Bases: FutureNewsError
The API answered with an HTTP error status.
Source code in src/futurenews/errors.py
13 14 15 16 17 18 19 | |
AuthRequiredError
¶
Bases: FutureNewsError
An endpoint needs a bearer token but the client has no auth_token.
Raised before any request is sent. Pass auth_token=... to the client.
Source code in src/futurenews/errors.py
42 43 44 45 46 | |
AuthenticationError
¶
Bases: APIError
HTTP 401: the bearer token is missing, invalid or expired.
Future News access tokens are short-lived (about 30 minutes), so refresh the token and build a new client.
Source code in src/futurenews/errors.py
49 50 51 52 53 54 | |
BlockedError
¶
Bases: APIError
Request was blocked (HTTP 403), typically a Cloudflare challenge.
Pass fresh browser cookies (e.g. cf_clearance) or a proxy
to the client. See the docs page on errors.
Source code in src/futurenews/errors.py
22 23 24 25 26 27 | |
ConnectionFailure
¶
Bases: FutureNewsError
Network-level failure (DNS, timeout, connection refused).
Source code in src/futurenews/errors.py
38 39 | |
FutureNewsError
¶
Bases: Exception
Base class for all errors raised by futurenews.
Source code in src/futurenews/errors.py
9 10 | |
RateLimitError
¶
Bases: APIError
Too many requests (HTTP 429). retry_after is in seconds if sent.
Source code in src/futurenews/errors.py
30 31 32 33 34 35 | |
Related: Authentication · Errors & Cloudflare · All endpoints
Don't have a Future News account?
Sign up with our link. It's free for you and supports this library.
Build something with this data
Chipa dev team builds trading bots and tools: Bot development · ChipaX exchange · Chipa Editor · Discord
Resources¶
Synchronous resource objects (client.trending, client.rank...).
Account
¶
Bases: _Resource
The signed-in account. Requires auth_token.
Source code in src/futurenews/resources/sync.py
81 82 83 84 85 86 | |
user_info()
¶
Fetch the current user's profile (POST /account/user_info).
Source code in src/futurenews/resources/sync.py
84 85 86 | |
Calendar
¶
Bases: _Resource
Finance calendar.
Source code in src/futurenews/resources/sync.py
50 51 52 53 54 55 | |
get(category, from_date, to_date)
¶
Fetch calendar entries, e.g. category="earnings" between two dates.
Source code in src/futurenews/resources/sync.py
53 54 55 | |
Events
¶
Bases: _Resource
Single event details.
Source code in src/futurenews/resources/sync.py
42 43 44 45 46 47 | |
get(slug)
¶
Fetch one Polymarket-backed event by slug (GET /api/v1/event/polymarket/{slug}).
Source code in src/futurenews/resources/sync.py
45 46 47 | |
Rank
¶
Bases: _Resource
Ranked market lists (new, trending...): POST /events/api/rank.
Source code in src/futurenews/resources/sync.py
34 35 36 37 38 39 | |
list(request=None, **overrides)
¶
Fetch a ranked list. overrides are RankRequest fields (e.g. rank_type="new").
Source code in src/futurenews/resources/sync.py
37 38 39 | |
Trending
¶
Bases: _Resource
Trending markets: POST /events/api/trending/list.
Source code in src/futurenews/resources/sync.py
21 22 23 24 25 26 27 28 29 30 31 | |
list(request=None, **overrides)
¶
Fetch trending markets. overrides are TrendingRequest fields (e.g. limit=10).
Raises:
| Type | Description |
|---|---|
ValueError
|
invalid options (checked before any request is sent). |
Source code in src/futurenews/resources/sync.py
24 25 26 27 28 29 30 31 | |
Twitter
¶
Bases: _Resource
Twitter/X activity attached to a market.
Source code in src/futurenews/resources/sync.py
58 59 60 61 62 63 | |
activity(event_slug, limit=10, cursor='')
¶
Fetch a page of tweets for an event. Pass the previous cursor to page.
Source code in src/futurenews/resources/sync.py
61 62 63 | |
Wallet
¶
Bases: _Resource
On-chain wallet data. Requires auth_token.
Source code in src/futurenews/resources/sync.py
66 67 68 69 70 71 72 73 74 75 76 77 78 | |
balances(wallet_address, chain='polygon', token_addresses=(), token_ids=())
¶
Fetch token balances for a wallet (GET /td/api/v1/wallet/balances).
Source code in src/futurenews/resources/sync.py
69 70 71 72 73 74 75 76 77 78 | |