Python client library for Datanews API
Project description
Datanews Python
This is a client library for python 3, built to interact with the Datanews API. You can find full api documentation at official documentation page.
Install
Use pip to install the library.
pip install datanews
Usage
To use the API, import the datanews
package and provide the api key. Then, proceed to make
queries by calling corresponding functions of the library.
Core API
import datanews
datanews.api_key = 'API_KEY'
response = datanews.headlines(q='SpaceX')
articles = response['hits']
print(articles[0]['title'])
Monitoring API
To create monitors use the datanews.Monitor
object.
To retrieve monitor runs use Monitor.latest
function and pass run_id
. Each
run object has a last_run_id
field, which refers to previous run, or None
,
if no runs were made previously (i.e. this was the first run). Please refer to
to full documentation of monitoring API.
import datanews
datanews.api_key = 'API_KEY'
# list all monitors
print(datanews.Monitor.list())
# create new monitor, pass query (list of keywords), and webhook url
monitor = datanews.Monitor.create(query='SpaceX', 'webhook'='https://mywebhook.com')
# get id of the monitor
id = monitor['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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file datanews-0.0.7.tar.gz
.
File metadata
- Download URL: datanews-0.0.7.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70ef3d6e58adb8489bd8f9e8e5d257c6cddc3868920f9db55d32592a66db9354 |
|
MD5 | 9da2fe691356614dd688e1f31d047094 |
|
BLAKE2b-256 | 8fb7678fe7ad4693c8ea12e818e0b91f4c74097a69c922d4315dc826a83414ec |
File details
Details for the file datanews-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: datanews-0.0.7-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edb1c94373df3211c7de3ddb84eedbd28a0111c005e411ad7ae9598d2282d1bd |
|
MD5 | 8f458045afcb71f0bb3407de018889a6 |
|
BLAKE2b-256 | a06117def7528f3d2e07a5df4122f1bea62595bd9e915851dfb3935960442635 |