Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Changelog

## Unreleased
- New endpoints: `rank.list`, `events.get`, `calendar.get`, `twitter.activity`, `wallet.balances`, `account.user_info`.
- `auth_token` client option, `AuthRequiredError`, `AuthenticationError`.
- Detailed per-endpoint docs and an authentication guide.

## 0.1.0
- Initial release: sync + async clients, `trending.list`, typed models, error hierarchy. By Chipa dev team.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ with FutureNews() as client:
```


## Endpoints

| Resource | Auth |
|---|---|
| `client.trending.list()` · `client.rank.list()` | no |
| `client.events.get(slug)` · `client.calendar.get(...)` · `client.twitter.activity(...)` | no |
| `client.wallet.balances(...)` · `client.account.user_info()` | bearer `auth_token` |

Every method has an `await`-able twin on `AsyncFutureNews`. Full docs: https://chipadevteam.github.io/FutureNewsAPI/

## Why this exists
Future News has no official Python SDK. This library gives you typed models, sync and async clients and clear errors for the Future News trending markets API.

Expand Down
36 changes: 36 additions & 0 deletions docs/authentication.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: Future News API authentication in Python (bearer token)
description: How to authenticate Future News API calls from Python with the futurenews library: bearer tokens, expiry, and keeping secrets safe.
---

# Authentication

Public endpoints (trending, rank, events, calendar, Twitter) need no login. **Wallet** and **account** endpoints need a bearer access token.

```python
import os
from futurenews import FutureNews

client = FutureNews(auth_token=os.environ["FUTURENEWS_TOKEN"])
```

- The token is sent as `Authorization: Bearer <token>` only on endpoints that need it.
- It is hidden from `repr(client)` and never logged.
- Calling an authenticated endpoint without a token raises `AuthRequiredError` before any network request.
- An invalid or expired token raises `AuthenticationError` (HTTP 401).

## Getting a token
The library does not log in for you. Access tokens are issued to your browser session when you are signed in at [future.news](https://future.news/41L85FOV); they are short-lived (about 30 minutes), so refresh and rebuild the client when you see `AuthenticationError`.

!!! danger "Treat tokens and cookies like passwords"
Never commit them, paste them in issues, or share curl commands that contain them. Use environment variables or a secrets manager. If a token leaks, sign out of Future News to invalidate your session.

---

**Related:** [Authentication](authentication.md) · [Errors & Cloudflare](errors.md) · [All endpoints](endpoints/index.md)

!!! tip "Don't have a Future News account?"
[Sign up with our link](https://future.news/41L85FOV). It's free for you and supports this library.

!!! info "Build something with this data"
Chipa dev team builds trading bots and tools: [Bot development](https://chipatrade.com/services/bot-development) · [ChipaX exchange](https://exchange.chipatrade.com/en/trade/BTC) · [Chipa Editor](https://chipaeditor.com) · [Discord](https://discord.com/invite/qwQZ7rHzGb)
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ pip install -e ".[dev,docs]"
pytest && ruff check . && mypy src
```

Adding an endpoint: add models in `models.py`, a resource in `resources/`, wire it in `client.py`, write respx tests first, add a docs page. Questions? [Discord](https://discord.com/invite/qwQZ7rHzGb).
Adding an endpoint: write respx tests first, add a pure builder returning a `Call` in `resources/_calls.py`, then one thin method each in `resources/sync.py` and `resources/asynchronous.py`, and a docs page under `docs/endpoints/` (add it to `mkdocs.yml`). Questions? [Discord](https://discord.com/invite/qwQZ7rHzGb).

Supporting the project is free: [sign up to Future News with our link](https://future.news/41L85FOV).
64 changes: 64 additions & 0 deletions docs/endpoints/account.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: Future News account API in Python: user info
description: Use client.account.user_info to fetch the signed-in Future News user profile from Python. Requires an auth token.
---

# Account: `account.user_info`

Fetches the profile of the signed-in user.

| | |
|---|---|
| HTTP | `POST https://future.news/account/user_info` (empty body) |
| Auth | **required**: `FutureNews(auth_token=...)`, see [Authentication](../authentication.md) |
| Returns | `ApiResponse` |

## Example (sync)

```python
import os
from futurenews import FutureNews, AuthenticationError

with FutureNews(auth_token=os.environ["FUTURENEWS_TOKEN"]) as client:
try:
print(client.account.user_info().data)
except AuthenticationError:
print("Token expired: get a fresh one and build a new client.")
```

## Example (async)

```python
import asyncio, os
from futurenews import AsyncFutureNews


async def main():
async with AsyncFutureNews(auth_token=os.environ["FUTURENEWS_TOKEN"]) as client:
print((await client.account.user_info()).data)


asyncio.run(main())
```

!!! warning "Personal data"
The response contains your account details. Don't paste it into public issues or logs.

## Equivalent request

```bash
curl -X POST 'https://future.news/account/user_info?from_app=future-web&os=web' \
-H 'authorization: Bearer <token>' -H 'content-length: 0'
```

!!! note "About the response"
Future News does not publish a schema. The library returns the payload as an [`ApiResponse`](../reference.md#futurenews.models.ApiResponse): `.data` holds the `"data"` field (or the whole JSON when there is none) and `.raw` always holds the untouched JSON. Unknown fields are never dropped. Field-level models are added once sample responses are confirmed, so treat the shape as subject to change.
---

**Related:** [Authentication](../authentication.md) · [Errors & Cloudflare](../errors.md) · [All endpoints](../endpoints/index.md)

!!! tip "Don't have a Future News account?"
[Sign up with our link](https://future.news/41L85FOV). It's free for you and supports this library.

!!! info "Build something with this data"
Chipa dev team builds trading bots and tools: [Bot development](https://chipatrade.com/services/bot-development) · [ChipaX exchange](https://exchange.chipatrade.com/en/trade/BTC) · [Chipa Editor](https://chipaeditor.com) · [Discord](https://discord.com/invite/qwQZ7rHzGb)
69 changes: 69 additions & 0 deletions docs/endpoints/calendar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: Future News finance calendar API in Python (earnings and more)
description: Use client.calendar.get to fetch the Future News finance calendar (earnings and other categories) between two dates from Python.
---

# Finance calendar: `calendar.get`

Fetches the finance calendar shown on the *Earnings calendar* tab of the trending page.

| | |
|---|---|
| HTTP | `GET https://future.news/api/v1/finance_calendar/polymarket` |
| Auth | none |
| Returns | `ApiResponse` |

## Parameters

| Parameter | Type | Notes |
|---|---|---|
| `category` | `str` | e.g. `"earnings"`. Non-empty. |
| `from_date` | `date \| str` | start, sent as `from=YYYY-MM-DD` |
| `to_date` | `date \| str` | end, sent as `to=YYYY-MM-DD` |

Strings must be ISO dates (`YYYY-MM-DD`); anything else raises `ValueError` before a request is made. (`from_date` is used because `from` is a Python keyword.)

## Example (sync)

```python
from datetime import date, timedelta
from futurenews import FutureNews

with FutureNews() as client:
today = date.today()
cal = client.calendar.get("earnings", today, today + timedelta(days=30))
print(cal.data)
```

## Example (async)

```python
import asyncio
from futurenews import AsyncFutureNews


async def main():
async with AsyncFutureNews() as client:
print((await client.calendar.get("earnings", "2026-11-29", "2026-12-29")).data)


asyncio.run(main())
```

## Equivalent request

```bash
curl 'https://future.news/api/v1/finance_calendar/polymarket?category=earnings&from=2026-11-29&to=2026-12-29&from_app=future-web&os=web'
```

!!! note "About the response"
Future News does not publish a schema. The library returns the payload as an [`ApiResponse`](../reference.md#futurenews.models.ApiResponse): `.data` holds the `"data"` field (or the whole JSON when there is none) and `.raw` always holds the untouched JSON. Unknown fields are never dropped. Field-level models are added once sample responses are confirmed, so treat the shape as subject to change.
---

**Related:** [Authentication](../authentication.md) · [Errors & Cloudflare](../errors.md) · [All endpoints](../endpoints/index.md)

!!! tip "Don't have a Future News account?"
[Sign up with our link](https://future.news/41L85FOV). It's free for you and supports this library.

!!! info "Build something with this data"
Chipa dev team builds trading bots and tools: [Bot development](https://chipatrade.com/services/bot-development) · [ChipaX exchange](https://exchange.chipatrade.com/en/trade/BTC) · [Chipa Editor](https://chipaeditor.com) · [Discord](https://discord.com/invite/qwQZ7rHzGb)
66 changes: 66 additions & 0 deletions docs/endpoints/events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: Future News event API in Python: get a market by slug
description: Use client.events.get(slug) to fetch a single Future News (Polymarket-backed) event by its slug from Python.
---

# Event details: `events.get`

Fetches one event (a market page on Future News) by its **slug**, the last part of the event URL.

| | |
|---|---|
| HTTP | `GET https://future.news/api/v1/event/polymarket/{slug}` |
| Auth | none |
| Returns | `ApiResponse` |

## Parameters

| Parameter | Type | Notes |
|---|---|---|
| `slug` | `str` | e.g. `"dota2-liquid-ty-2026-11-29"`. Must be non-empty. It is URL-encoded, and slugs made only of dots (`.`, `..`) are rejected, so a slug cannot alter the request path. |

## Example (sync)

```python
from futurenews import FutureNews

with FutureNews() as client:
event = client.events.get("dota2-liquid-ty-2026-11-29")
print(event.data)
```

## Example (async)

```python
import asyncio
from futurenews import AsyncFutureNews


async def main():
async with AsyncFutureNews() as client:
print((await client.events.get("dota2-liquid-ty-2026-11-29")).data)


asyncio.run(main())
```

## Where do slugs come from?
Call [`rank.list`](rank.md) or [`trending.list`](trending.md) and read the slug of each entry, or copy it from the event URL on future.news.

## Equivalent request

```bash
curl 'https://future.news/api/v1/event/polymarket/dota2-liquid-ty-2026-11-29?from_app=future-web&os=web'
```

!!! note "About the response"
Future News does not publish a schema. The library returns the payload as an [`ApiResponse`](../reference.md#futurenews.models.ApiResponse): `.data` holds the `"data"` field (or the whole JSON when there is none) and `.raw` always holds the untouched JSON. Unknown fields are never dropped. Field-level models are added once sample responses are confirmed, so treat the shape as subject to change.
---

**Related:** [Authentication](../authentication.md) · [Errors & Cloudflare](../errors.md) · [All endpoints](../endpoints/index.md)

!!! tip "Don't have a Future News account?"
[Sign up with our link](https://future.news/41L85FOV). It's free for you and supports this library.

!!! info "Build something with this data"
Chipa dev team builds trading bots and tools: [Bot development](https://chipatrade.com/services/bot-development) · [ChipaX exchange](https://exchange.chipatrade.com/en/trade/BTC) · [Chipa Editor](https://chipaeditor.com) · [Discord](https://discord.com/invite/qwQZ7rHzGb)
28 changes: 28 additions & 0 deletions docs/endpoints/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: Future News API endpoints (Python reference)
description: All Future News API endpoints supported by the futurenews Python library: trending, rank, events, calendar, Twitter activity, wallet and account.
---

# Endpoints

| Resource | Method | Auth | Page |
|---|---|---|---|
| `client.trending.list()` | `POST /events/api/trending/list` | no | [Trending](trending.md) |
| `client.rank.list()` | `POST /events/api/rank` | no | [Rank](rank.md) |
| `client.events.get(slug)` | `GET /api/v1/event/polymarket/{slug}` | no | [Events](events.md) |
| `client.calendar.get(...)` | `GET /api/v1/finance_calendar/polymarket` | no | [Calendar](calendar.md) |
| `client.twitter.activity(...)` | `GET /fds/api/v1/market/twitter/activity/list` | no | [Twitter](twitter.md) |
| `client.wallet.balances(...)` | `GET /td/api/v1/wallet/balances` | **yes** | [Wallet](wallet.md) |
| `client.account.user_info()` | `POST /account/user_info` | **yes** | [Account](account.md) |

Every method has an identical `await`-able twin on `AsyncFutureNews`.

---

**Related:** [Authentication](../authentication.md) · [Errors & Cloudflare](../errors.md) · [All endpoints](../endpoints/index.md)

!!! tip "Don't have a Future News account?"
[Sign up with our link](https://future.news/41L85FOV). It's free for you and supports this library.

!!! info "Build something with this data"
Chipa dev team builds trading bots and tools: [Bot development](https://chipatrade.com/services/bot-development) · [ChipaX exchange](https://exchange.chipatrade.com/en/trade/BTC) · [Chipa Editor](https://chipaeditor.com) · [Discord](https://discord.com/invite/qwQZ7rHzGb)
78 changes: 78 additions & 0 deletions docs/endpoints/rank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
title: Future News rank API in Python: new, trending and ranked markets
description: Use client.rank.list to fetch ranked Future News market lists (new, trending, by volume) from Python. Sync and async examples.
---

# Rank list: `rank.list`

Fetches the ranked market lists behind the tabs on the Future News trending page (for example **New** or **Trending**). It is the same list shape as [`trending.list`](trending.md), with a few extra filters.

| | |
|---|---|
| HTTP | `POST https://future.news/events/api/rank` |
| Auth | none |
| Returns | `RankResponse` (`.items`, a list of entries; unknown fields kept) |

## Parameters

Pass them as keyword arguments or build a `RankRequest`.

| Parameter | Type | Default | Notes |
|---|---|---|---|
| `rank_type` | `str` | `"trending"` | e.g. `"new"`, `"trending"` |
| `order_by` | `str` | `"volume24h"` | e.g. `"create_timestamp"` for newest first |
| `limit` | `int` | `100` | 1 to 100 (strict integer) |
| `status` | `list[str]` | `["active"]` | |
| `categories`, `subcategories` | `list[str]` | `[]` | |
| `exclude_series` | `bool` | `False` | hide recurring series markets |
| `exclude_tags` | `list[str]` | `[]` | tag ids to hide; omitted from the body when empty |
| `market_status` | `str \| None` | `None` | omitted from the body when unset |

Misspelled options raise `ValueError` before any request is sent.

## Example (sync)

```python
from futurenews import FutureNews

with FutureNews() as client:
newest = client.rank.list(rank_type="new", order_by="create_timestamp", limit=20, exclude_series=True)
for item in newest.items:
print(item.model_dump())
```

## Example (async)

```python
import asyncio
from futurenews import AsyncFutureNews


async def main():
async with AsyncFutureNews() as client:
res = await client.rank.list(rank_type="new", limit=20)
print(len(res.items))


asyncio.run(main())
```

## Equivalent request

```bash
curl 'https://future.news/events/api/rank?from_app=future-web&os=web&app_lang=en-US' \
-H 'content-type: application/json' \
--data-raw '{"exclude_series":true,"rank_type":"new","categories":[],"subcategories":[],"status":["active"],"order_by":"create_timestamp","limit":100}'
```

The library adds the remaining query parameters (`device_id`, `client_id`, `app_ver`...) for you. If Cloudflare answers 403, see [Errors & Cloudflare](../errors.md).

---

**Related:** [Authentication](../authentication.md) · [Errors & Cloudflare](../errors.md) · [All endpoints](../endpoints/index.md)

!!! tip "Don't have a Future News account?"
[Sign up with our link](https://future.news/41L85FOV). It's free for you and supports this library.

!!! info "Build something with this data"
Chipa dev team builds trading bots and tools: [Bot development](https://chipatrade.com/services/bot-development) · [ChipaX exchange](https://exchange.chipatrade.com/en/trade/BTC) · [Chipa Editor](https://chipaeditor.com) · [Discord](https://discord.com/invite/qwQZ7rHzGb)
Loading
Loading