A Tiny package for cXense API
Make cXense API simple.
Requirements
Python 3.6 above (did't test in other versions)
Installation
pip install pyCx
How to use
Step 1: create a Cx object with env.yaml by using CxConfig
import os
from pyCx import Cx, CxConfig
# using env.yaml
fp = os.path.abspath('env.yaml')
cx = Cx(CxConfig(fp))
# or just passing dict value
my_cx_config = {
'site_id': YOUR_ID,
'username': 'YOUR_USERNAME',
'secret': 'YOUR_KEY',
'apiserver': 'https://api.cxense.com',
}
cx = Cx(my_cx_config)
and here's env.yaml sample:
default:
site_id: YOUR_ID
username: YOUR_USERNAME
secret: YOUR_KEY
apiserver: https://api.cxense.com
Step 2: send a /traffic request by using CxQuery
import json
from pyCx import Cx, CxenseURL
from pyCx.helpers import date_range
cx = Cx(my_cx_config)
# get CxQuery object from Cx
query = cx.get_query()
# apply date range for what we want, here will get data from 11/01 to 11/30 (include).
dates = date_range('2018-11-01', '2018-12-01')
# remember do a reset() before a new request.
status, header, content = query.reset() \
.uri(CxenseURL.TRAFFIC) \
.add_filter({'type': 'and', 'filters': [{'group': "PREFIX-articleid", 'items': ['123405'], 'type': "keyword"}]}) \
.add_fields(['events', 'uniqueUsers']) \
.add_history_fields(['events', 'uniqueUsers']) \
.add_dates(dates) \
.send()
# print results
result = json.loads(content.decode('utf-8'))
print(result)
- you can find API URI lists from CxenseURL
Docs
TODO
Contributors
Lastest Version
0.0.11 (Lastest, 2018/12/13)
License
MIT
Metadata
Release files for pyCx 0.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyCx-0.0.12.tar.gz | 7.4 kB | Without provenance | Details |
Release files / pyCx-0.0.12.tar.gz
| Download URL | pyCx-0.0.12.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ba6f231d7c1d395e49c2051ae522c3dfbafb12ac19e7e3e38d2aeeba9de92cc
|
|
BLAKE2b-256 checksum How to use checksums |
f866dae2dc7e9c2d8935d64a868bd79ea28ee3fafc60fe1da0e39032b7c04e14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6
|
Security for pyCx 0.0.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.