<commit_before>
Zencoder
--------

[![Build Status](https://travis-ci.org/zencoder/zencoder-py.svg?branch=master)](https://travis-ci.org/zencoder/zencoder-py)

A Python module for interacting with the [Zencoder](http://zencoder.com) API.

### Getting Started

Install from PyPI

    $ pip install zencoder

Import zencoder

```python
from zencoder import Zencoder
```

Create an instance of the Zencoder client. This will accept an API key and version. If not API key is set, it will look for a `ZENCODER_API_KEY` environment variable. API version defaults to 'v2'.

```python
# If you want to specify an API key when creating a client
client = Zencoder('API_KEY')

# If you have the environment variable set
client = Zencoder()
```

## [Jobs](https://app.zencoder.com/docs/api/jobs)

Create a [new job](https://app.zencoder.com/docs/api/jobs/create).

```python
client.job.create('s3://bucket/key.mp4')
client.job.create('s3://bucket/key.mp4',
               outputs=[{'label': 'vp8 for the web',
                         'url': 's3://bucket/key_output.webm'}])
```

This returns a `zencoder.Response` object. The body includes a Job ID, and one or more Output IDs (one for every output file created).

```python
response = client.job.create('s3://bucket/key.mp4')
response.code           # 201
response.body['id']     # 12345
```

[List jobs](https://app.zencoder.com/docs/api/jobs/list).

By default the jobs listing is paginated with 50 jobs per page and sorted by ID in descending order. You can pass two parameters to control the paging: `page` and `per_page`.

```python
client.job.list(per_page=10)
client.job.list(per_page=10, page=2)
```

Get [details](https://app.zencoder.com/docs/api/jobs/show) about a job.

The number passed to `details` is the ID of a Zencoder job.

```python
client.job.details(1)
```

Get [progress](https://app.zencoder.com/docs/api/jobs/progress) on a job.

The number passed to `progress` is the ID of a Zencoder job.

```python
client.job.progress(1)
```

[Resubmit](https://app.zencoder.com/docs/api/jobs/resubmit) a job

The number passed to `resubmit` is the ID of a Zencoder job.

```python
client.job.resubmit(1)
```

[Cancel](https://app.zencoder.com/docs/api/jobs/cancel) a job

The number passed to `cancel` is the ID of a Zencoder job.

```python
client.job.cancel(1)
```

## [Inputs](https://app.zencoder.com/docs/api/inputs)

Get [details](https://app.zencoder.com/docs/api/inputs/show) about an input.

The number passed to `details` is the ID of a Zencoder job.

```python
client.input.details(1)
```

Get [progress](https://app.zencoder.com/docs/api/inputs/progress) for an input.

The number passed to `progress` is the ID of a Zencoder job.

```python
client.input.progress(1)
```
## [Outputs](https://app.zencoder.com/docs/api/outputs)

Get [details](https://app.zencoder.com/docs/api/outputs/show) about an output.

The number passed to `details` is the ID of a Zencoder job.

```python
client.output.details(1)
```

Get [progress](https://app.zencoder.com/docs/api/outputs/progress) for an output.

The number passed to `progress` is the ID of a Zencoder job.

```python
client.output.progress(1)
```

## [Reports](https://app.zencoder.com/docs/api/reports)

Reports are great for getting usage data for your account. All default to 30 days from yesterday with no [grouping](https://app.zencoder.com/docs/api/encoding/job/grouping), but this can be altered. These will return `422 Unprocessable Entity` if the date format is incorrect or the range is greater than 2 months. 

Get [all usage](https://app.zencoder.com/docs/api/reports/all) (Live + VOD).

```python
import datetime
client.report.all()
client.report.all(grouping="foo")
client.report.all(start_date=datetime.date(2011, 10, 30),
                end_date=datetime.date(2011, 11, 24))
client.report.all(start_date=datetime.date(2011, 10, 30),
                end_date=datetime.date(2011, 11, 24),
                grouping="foo")
```

Get [VOD usage](https://app.zencoder.com/docs/api/reports/vod).

```python
import datetime
client.report.vod()
client.report.vod(grouping="foo")
client.report.vod(start_date=datetime.date(2011, 10, 30),
               end_date=datetime.date(2011, 11, 24))
client.report.vod(start_date=datetime.date(2011, 10, 30),<commit_msg>Fix documentation. Numbers passed into input and outputs methods are input and output IDs, not job IDs.<commit_after>
Zencoder
--------

[![Build Status](https://travis-ci.org/zencoder/zencoder-py.svg?branch=master)](https://travis-ci.org/zencoder/zencoder-py)

A Python module for interacting with the [Zencoder](http://zencoder.com) API.

### Getting Started

Install from PyPI

    $ pip install zencoder

Import zencoder

```python
from zencoder import Zencoder
```

Create an instance of the Zencoder client. This will accept an API key and version. If not API key is set, it will look for a `ZENCODER_API_KEY` environment variable. API version defaults to 'v2'.

```python
# If you want to specify an API key when creating a client
client = Zencoder('API_KEY')

# If you have the environment variable set
client = Zencoder()
```

## [Jobs](https://app.zencoder.com/docs/api/jobs)

Create a [new job](https://app.zencoder.com/docs/api/jobs/create).

```python
client.job.create('s3://bucket/key.mp4')
client.job.create('s3://bucket/key.mp4',
               outputs=[{'label': 'vp8 for the web',
                         'url': 's3://bucket/key_output.webm'}])
```

This returns a `zencoder.Response` object. The body includes a Job ID, and one or more Output IDs (one for every output file created).

```python
response = client.job.create('s3://bucket/key.mp4')
response.code           # 201
response.body['id']     # 12345
```

[List jobs](https://app.zencoder.com/docs/api/jobs/list).

By default the jobs listing is paginated with 50 jobs per page and sorted by ID in descending order. You can pass two parameters to control the paging: `page` and `per_page`.

```python
client.job.list(per_page=10)
client.job.list(per_page=10, page=2)
```

Get [details](https://app.zencoder.com/docs/api/jobs/show) about a job.

The number passed to `details` is the ID of a Zencoder job.

```python
client.job.details(1)
```

Get [progress](https://app.zencoder.com/docs/api/jobs/progress) on a job.

The number passed to `progress` is the ID of a Zencoder job.

```python
client.job.progress(1)
```

[Resubmit](https://app.zencoder.com/docs/api/jobs/resubmit) a job

The number passed to `resubmit` is the ID of a Zencoder job.

```python
client.job.resubmit(1)
```

[Cancel](https://app.zencoder.com/docs/api/jobs/cancel) a job

The number passed to `cancel` is the ID of a Zencoder job.

```python
client.job.cancel(1)
```

## [Inputs](https://app.zencoder.com/docs/api/inputs)

Get [details](https://app.zencoder.com/docs/api/inputs/show) about an input.

The number passed to `details` is the ID of a Zencoder input.

```python
client.input.details(1)
```

Get [progress](https://app.zencoder.com/docs/api/inputs/progress) for an input.

The number passed to `progress` is the ID of a Zencoder input.

```python
client.input.progress(1)
```
## [Outputs](https://app.zencoder.com/docs/api/outputs)

Get [details](https://app.zencoder.com/docs/api/outputs/show) about an output.

The number passed to `details` is the ID of a Zencoder output.

```python
client.output.details(1)
```

Get [progress](https://app.zencoder.com/docs/api/outputs/progress) for an output.

The number passed to `progress` is the ID of a Zencoder output.

```python
client.output.progress(1)
```

## [Reports](https://app.zencoder.com/docs/api/reports)

Reports are great for getting usage data for your account. All default to 30 days from yesterday with no [grouping](https://app.zencoder.com/docs/api/encoding/job/grouping), but this can be altered. These will return `422 Unprocessable Entity` if the date format is incorrect or the range is greater than 2 months. 

Get [all usage](https://app.zencoder.com/docs/api/reports/all) (Live + VOD).

```python
import datetime
client.report.all()
client.report.all(grouping="foo")
client.report.all(start_date=datetime.date(2011, 10, 30),
                end_date=datetime.date(2011, 11, 24))
client.report.all(start_date=datetime.date(2011, 10, 30),
                end_date=datetime.date(2011, 11, 24),
                grouping="foo")
```

Get [VOD usage](https://app.zencoder.com/docs/api/reports/vod).

```python
import datetime
client.report.vod()
client.report.vod(grouping="foo")
client.report.vod(start_date=datetime.date(2011, 10, 30),
               end_date=datetime.date(2011, 11, 24))
client.report.vod(start_date=datetime.date(2011, 10, 30),
{'fraction_non_alphanumeric': 0.14752772643253234, 'fraction_numerical': 0.021719038817005546, 'mean_word_length': 3.9781483611270847, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 38, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4165044', 'n_tokens_mistral': 3028, 'n_tokens_neox': 2812, 'n_words': 823}