Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (testpypi.python.org).
Help us improve Python packaging - Donate today!

A Python client for Decipher's Beacon API

Project Description
#Decipher

[![Build Status](https://api.shippable.com/projects/540e6d593479c5ea8f9e4335/badge?branchName=master)](https://app.shippable.com/projects/540e6d593479c5ea8f9e4335/builds/latest)

Python client for [Decipher](https://www.decipherinc.com) data and survey list API.

## Installation

git clone git@github.com:InContextSolutions/Decipher.git
cd Decipher
pip install .

## Usage

### Create a client

Creating a client requires your decipher username and password.

```python
from decipher.client import Client
c = Client('you@example.org', 'Pa$$w0rd123')
```

By default, the client refers to the `v2.decipherinc.com/api` host. Alternate hosts can be specified in the constructor:

```python
c = Client('you@example.org', 'Pa$$w0rd123', host='custom.decipherinc.com/api')
```

All hosts are assumed to be over SSL (`https`).

### Retrieve list of available surveys

You can retrieve a list of all surveys in three formats:

- `json`: JavaScript Object Notation
- `csv`: comma-separated values
- `tsv`: tab-separated values

```python
c.list_surveys(fmt='json')
```

### Pull data for a specific survey

```python
c.get_survey(survey, start=None, end=None, status=None, columns=None, filters=None, fmt='json')
```

- `survey` is the full survey path
- `start` and `end` are Python datetimes (assumes UTC)
- `columns` is a list of column names to include in the results
- `filters` is a list of column-specific rules
- As above, `fmt` is the return format and can be `json`, `csv`, or `tsv`

### Command-line interface (CLI)

Included with the installation is a command-line utlity called `decipher` with built-in help:

```shell
$ decipher --help
usage: decipher [-h] -U USERNAME -P PASSWORD [-H HOST] {pull,list} ...

A command-line utility for interacting with the Decipher API. Help is
available on subcommands (e.g. `decipher pull --help`)

optional arguments:
-h, --help show this help message and exit
-U USERNAME, --username USERNAME
user identification
-P PASSWORD, --password PASSWORD
user password
-H HOST, --host HOST host

valid subcommands:
{pull,list}
pull pull survey data
list list surveys
```

#### Get survey data

```shell
$ decipher pull --help
usage: decipher pull [-h] -s SURVEY [-t START] [-T END]
[-S {all,partial,complete,qualified,terminated,overquota}]
[-c COLUMNS] [-F FILTERS] [-f {json,tsv,csv}]

optional arguments:
-h, --help show this help message and exit
-s SURVEY, --survey SURVEY
survey name
-t START, --start START
utc start time: YYYY-MM-DDTHH:MM:SS.mmmmmm
-T END, --end END utc end time: YYYY-MM-DDTHH:MM:SS.mmmmmm
-S {all,partial,complete,qualified,terminated,overquota}, --status {all,partial,complete,qualified,terminated,overquota}
survey status
-c COLUMNS, --columns COLUMNS
columns
-F FILTERS, --filters FILTERS
filter conditions
-f {json,tsv,csv}, --fmt {json,tsv,csv}
return format
```

Example:

```shell
$ decipher -U dataapi -P dataapi pull -s 'kbdemo/data' -f csv -S qualified -c uuid,q1 -F 'q1=2'
```

#### Get list of surveys

```shell
$ decipher list --help
usage: decipher list [-h] [-f {json,tsv,csv}]

optional arguments:
-h, --help show this help message and exit
-f {json,tsv,csv}, --fmt {json,tsv,csv}
return format
```

Example:

```shell
$ decipher -U dataapi -P dataapi list -f csv
```
Release History

Release History

This version
History Node

0.1

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting