Skip to content

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.

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; they are short-lived (about 30 minutes), so refresh and rebuild the client when you see AuthenticationError.

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 · 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