Python Example
Install socket.io for Python:
pip install python-engineio==3.14.2 python-socketio[client]==4.6.0
Please use the exact
python-engineio
andpython-socketio
versions above.
The simple example below creates a socket.io client, connects to our server and prints all articles as they are received.
import socketio
sio = socketio.Client()
@sio.on('connect')
def on_connect():
print("Connected to Newsfilter Stream API")
@sio.on('articles')
def on_articles(articles):
print(articles)
sio.connect('http://stream.newsfilter.io?apiKey=YOUR_API_KEY')
sio.wait()
Learn more about socket.io for Python here: https://python-socketio.readthedocs.io/en/latest/client.html