Skip to main content

API: Requesting real-time data

Simple instructions on querying real-time data by establishing a WebSocket connection.

  1. Use a WebSocket endpoint leading to wss://app.readpartner.com/api/v1/monitoring.

  2. Establish an active WebSocket connection passing your desired search filters in the URL. (You can expirement with URL params here: https://app.readpartner.com/api-dashboard/playground)

  3. The backend will send an event with event=status and message=Task started.

  4. The next event with event=result will contain the result items for selected platforms in the data field. The results will be sorted by newest and are limited to 20 entries.

python

import asyncio 
import json
import websockets

URL = "wss://app.readpartner.com/api/v1/monitoring?q=search_keyword" API_KEY = "your_api_key"

async def process(api_items):
for item in api_items:
print(item)

async def listen():
async with websockets.connect(URL, additional_headers={"X-API-Key": API_KEY}) as ws:
async for message in ws:
data = json.loads(message)

if data["event"] == "status":
print(data["message"])

if data["event"] == "result":
await process(data["data"])

asyncio.run(listen())

Questions? Feel free to reach out to your account manager or via support chat.

Did this answer your question?