This library serves as the official Python client to the
[Plenario API](https://plenario.docs.apiary.io/#).
## Requirements
This will run on Python 3.6 or better. Older versions of Python are not
supported. This library requires the installation of the
[requests library](http://docs.python-requests.org/en/master/).
## Usage
There are 2 API endpoints to Plenario:
- The list endpoint that gets metadata about the data sets
- The detail endpoint that gets records from the data sets
### Accessing Data Set Records
Plenario API responses are paginated, so naturally we need to provide users
with the ability to page through data as easily as possible. To do this, we
provide a simple iterator baked into the data sets:
```python
from plenario_client import PlenarioClient
client = PlenarioClient()
data_set = client.get_data_set('chicago-stuff')
for page in data_set:
do_something_with_the(page)
```
The _page_ here is the response object: it has a `meta` attribute that includes
the response metadata and a `records` attribute that includes the response
body -- a list of dictionaries.
### Filtering with Query Parameters
Filtering can be a little complicated depending on your needs. To handle that,
we've come up with a pretty simple solution. Somewhat similar to Django and
Elasticsearch-DSL we have an `F` class with which you construct and compose
query parameters to filter the results.
There are three operations:
- Basic init with `F('field name', 'query operator', 'query value')`
- Appending filters with `F() &= F()`
- Overriding filters with `F() |= F()`
Here's an example:
```python
from plenario_client import PlenarioClient, F
# let's build a filter where we want items whose name is 'vince'
# and their age is greater than or equal to 21:
params = F('name', 'eq', 'vince')
params &= ('age', 'ge', 21) # appending works with either an F or a tuple
# let's now say we want to add 'bob' to the filter as well:
params &= ('name', 'eq', 'bob')
# at this point if we inspect the filter we would get something like
{
'name': [
('eq', 'vince'),
('eq', 'bob')
],
'age': ('ge', 21)
}
# now let's say that due to some logic happening in our script,
# we've determined that neither 'vince' nor 'bob' are desireable
# values -- we need 'alice':
params |= ('name', 'eq', 'alice')
# now under the hood, our filter looks like
{
'name': ('eq', 'alice'),
'age': ('ge', 21)
}
# now we're ready to fire off the request:
client = PlenarioClient()
client.describe_data_sets(params=params)
```
## Developing and Contributing
To run the tests locally:
```bash
$ pipenv install --dev
$ pipenv run python -m pytest
```
To push a relase to PyPI:
```bash
$ pipenv run python setup.py sdist bdist_wheel
$ pipenv run twine upload dist/*
```
Metadata
Release files for plenario-client 0.9.0
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 | |
|---|---|---|---|---|
| plenario-client-0.9.0.tar.gz | 5.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| plenario_client-0.9.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.8 kB
Release files / plenario-client-0.9.0.tar.gz
| Download URL | plenario-client-0.9.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2825e93c76c68136b3c7889199f7fb1fbd364f857050dc136596e130d9244006
|
|
BLAKE2b-256 checksum How to use checksums |
856b7353b3a05bcb2b213f786365a50f46ac932f935bf5ef67dd4b97bf532960
|
| 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/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Release files / plenario_client-0.9.0-py3-none-any.whl
| Download URL | plenario_client-0.9.0-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8badb231912a5dd7385536aa3ce3da1f6da54b72981ebd429f27e066c1bf404b
|
|
BLAKE2b-256 checksum How to use checksums |
c309f9fb543bc9bf307777e4c37ef913635a2c1608ed6d45252f08bff3f31ff2
|
| 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/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Security for plenario-client 0.9.0
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.