Skip to main content

Python library to access the Pluvo REST API.

Project description

# Pluvo Python

[![Build Status](http://img.shields.io/travis/wendbv/pluvo-python.svg)](https://travis-ci.org/wendbv/pluvo-python)
[![Coverage Status](http://img.shields.io/coveralls/wendbv/pluvo-python.svg)](https://coveralls.io/r/wendbv/pluvo-python)
[![MIT License](https://img.shields.io/badge/license-MIT-green.svg)](https://tldrlegal.com/license/mit-license)

Python library to access the Pluvo REST API.

## Authentication using client credentials

To access the methods that need authentication with client credentials, for
instance getting data for a specific user:

```python
from pluvo import Pluvo

pluvo = Pluvo(client_id='client_id', client_secret='client_secret')

user = pluvo.get_user(1)
```

## Authentication using token

To access methods that need a token to authenticate.

```python
from pluvo import Pluvo

pluvo = Pluvo(token='token')

user = pluvo.get_user(1)
```

## API list endpoints

Methods for API endpoints that return a list will return a `PluvoGenerator`
instance. The first page of the results is immediately retrieved. The length
of the instance will be the total number of items. The instance implements
an iterator, fetching more pages as nessecary.

See this example with a total of 50 courses in Pluvo.

```python
from pluvo import Pluvo

pluvo = Pluvo(client_id='client_id', client_secret='client_secret')

# Only the first 20 courses and the total number of courses are retrieved.
courses = pluvo.get_courses()

# No extra request is done.
len(courses) # 50

# Two more pages are retrieved.
list(courses) # [...]
```

### Altering page size

The default page size of 20 can be changed when instantiating the `Pluvo`
object.

```pluvo
from pluvo import Pluvo

pluvo = Pluvo(
client_id='client_id', client_secret='client_secret', page_size=50)
```

## API errors

When an API error is encountered an `PluvoAPIException` is raised.

```python
from pluvo import Pluvo, PluvoAPIException

# Not authenticated.
pluvo = Pluvo(client_id='invalid', client_secret='invalid')

try:
pluvo.get_course(1)
except PluvoAPIException as e:
e.message # 'Provided client_id or client_secret are invalid.'
e.status_code # 403
str(e) # 'HTTP status 403 - Provided client_id or client_secret are invalid.'
```

## General errors

All errors thrown by the library that are not a result of an API error will be
`PluvoException` errors. This is also the base class for `PluvoAPIException`.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pluvo-0.2.4.tar.gz (8.5 kB view details)

Uploaded Source

File details

Details for the file pluvo-0.2.4.tar.gz.

File metadata

  • Download URL: pluvo-0.2.4.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pluvo-0.2.4.tar.gz
Algorithm Hash digest
SHA256 14dd2bc57582e25f6465f1a5f02fab003f3f0002c9011624add2b2e73f59cacd
MD5 1581984a57b2fb628df3649e911ee8ac
BLAKE2b-256 ccc5a2d1e712088a9d0eb502ac6412c3c2605ae4054728de8df9715b642276d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page