Skip to content

Real-time news over WebSocket - #27

Merged
himanshu-gtm merged 6 commits into
mainfrom
feature/websocket
Aug 18, 2026
Merged

Real-time news over WebSocket#27
himanshu-gtm merged 6 commits into
mainfrom
feature/websocket

Conversation

@himanshu-gtm

Copy link
Copy Markdown
Collaborator

What's New

  • Added real-time news streaming over WebSocket — register a query once and receive matching articles as they're published.
  • Added websocket_fetch() and websocket_delete() for managing registrations.
  • Added stream_async() for asyncio applications.
  • Automatic reconnection with capped exponential backoff.

Breaking Changes

  • Python 3.10+ is now required.
  • websockets is now a required dependency.
  • pip install newsdataapi installs all required dependencies.
  • Python 3.8/3.9 users will continue receiving v0.2.3.

himanshu added 6 commits June 22, 2026 14:00
Real-time queries can now be registered, listed, and deleted from the SDK
instead of only consumed, and the two streaming consumers collapse into one
class.
- NewsDataApiWebSocket takes a NewsDataApiClient and adds websocket_register(),
websocket_fetch(), and websocket_delete(). They go through the client's
_request(), which gains a `method` argument for POST/DELETE, so they inherit
its session reuse, retry/backoff, and exception mapping. Registration always
targets the latest feed.
- registration_id moves from the constructor to stream()/stream_async(), so a
single instance can register a query and then stream it.
- NewsDataApiWebSocketAsync merges into NewsDataApiWebSocket as stream_async(),
and the _BaseNewsDataApiWebSocket base class is gone. Sync and async
connections are tracked separately so `with` and `async with` only ever close
their own socket.
- Fix the stream payload field: frames carry articles under `results`, not
`items`, so the consumer would have yielded nothing against the live server.
Each frame is now yielded whole; malformed frames are skipped instead of
ending the stream.
- websockets becomes a required dependency rather than the optional `websocket`
extra. It needs Python 3.10, which becomes the floor (3.8 and 3.9 are both
past end of life); classifiers, the CI matrix, ruff's target-version and
mypy's python_version follow.
- Version 0.3.0: 0.2.3 is already published on PyPI, and the raised Python
floor plus the new required dependency call for a minor bump.
@himanshu-gtm
himanshu-gtm merged commit 59d5431 into mainAug 18, 2026
7 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@himanshu-gtm