You can retrieve latest monitoring results using api.datanews.io/v1/monitors/latest/{run_id}
endpoint.
Get the latest run_id
from the monitor last_run_id
field. Then use it to query the endpoint.
curl -XGET 'api.datanews.io/v1/monitors/latest/{run_id}'
{
"id": "85219cd9652e4f02a22d92aa23c15675",
"monitor_id": "dfc22b6dc636494e8a02b58250eda2b5",
"query": "Netflix",
"run_time": "2020-09-14T10:07:56.685901",
"last_run_id": null,
"last_run_time": null,
"articles": [
{
"url": "https://junkee.com/cuties-netflix-contoversy-cancelnetflix-explainer/270619",
"source": "junkee.com",
"authors": [],
"title": "How Netflix's 'Cuties' Became The Most Misunderstood Film Of The Year - Junkee",
"pubDate": "2020-09-14T07:24:56+00:00",
"country": "",
"language": "en",
"description": "How Netflix's 'Cuties' Became The Most Misunderstood Film Of The Year Junkee",
"imageUrl": "https://junkee.com/wp-content/uploads/2020/09/cuties-netflix.jpg",
"content": "In February, 'Cuties' was a film festival favourite. Now, 600,000 people have signed a petition demanding everyone involved be charged with child exploitation.\n\nCuties, a French film acquired and dubbed into 40+ languages by Netflix after it received ... [+7501 chars]"
},
...
]
}
Here is an example code to retrieve all of the articles using the provided client library.
import datanews
datanews.api_key = 'API_KEY'
# prepare monitor id
id = datanews.Monitor.list()[0]['id']
# retrieve the monitor
monitor = datanews.Monitor.get(id)
# list latest articles from the Monitor
articles = []
run_id = monitor.get('last_run_id', None)
done = run_id is None
while not done:
run = datanews.Monitor.latest(run_id)
articles.extend(run['articles'])
run_id = run['last_run_id']
done = run_id is None
print(len(articles))