# yleapi

> Yleisradio API client for nodejs

Latest version **0.1.2** (published 2015-05-23) · 0 weekly downloads

## Install

```sh
npm install yleapi
pnpm add yleapi
yarn add yleapi
bun add yleapi
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2015-05-23 |
| First published | 2015-05-18 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | @joonapaak |
| Maintainers | pxu |

## Links

- npm: https://www.npmjs.com/package/yleapi
- Repository: https://github.com/paksu/yleapijs
- Issues: https://github.com/paksu/yleapijs/issues
- npm.io page: https://npm.io/package/yleapi

## Dependencies (3)

- [q](https://npm.io/package/q.md) ^1.4.1
- [extend](https://npm.io/package/extend.md) ^2.0.1
- [debuglog](https://npm.io/package/debuglog.md) ^1.0.1

## Recent versions

- 0.1.2 (latest) — 2015-05-23
- 0.1.1 — 2015-05-18
- 0.1.0 — 2015-05-18

## README

Simple promise based API client for YLE API http://developer.yle.fi/

by [@joonapaak](http://twitter.com/joonapaak)

### Install
`$ npm install yleapi`


### Initialize
```
var YleAPI = require('yleapi');

var api = new YleAPI({
    APP_ID: 'appid',
    APP_KEY: 'appkey',
    MEDIA_DECRYPT_KEY: 'secret' // not required to use HTTP API but needed if you want to decrypt media urls
});
```

### API
```
// get and filter stuff from a single endpoint
// returns a promise
api.get('resource/path', {params})

// decrypt media urls with your secret key
// returns the encrypted url
api.decryptMediaUrl(encryptedUrl)
```

### Examples
```
// get most popular programs
api.get('programs/items', {
    order: 'playcount.24h:desc',
    offset: 150
}).then(function(response) {
    // do stuff with the result
    console.log(response.meta);
    console.log(response.data);
})
.catch(function(error) {
    console.log("got error", error.statusCode, error.responseBody);
})


// get a program and decrypt media url
api.get('media/playouts', {
  program_id: '1-820561',
  media_id: '6-8e9d45c1221544f3be76394fa1a6a102',
  protocol: 'HLS'
}).then(function(response) {
  var mediaUrl = api.decryptMediaUrl(response.data[0].url);
});

```

### Logging
YleAPI uses `util.debuglog`. To requests run your script with `NODE_DEBUG`:

`$ env NODE_DEBUG=yleapi node myscript.js`

### Develop
**Run tests:** `$ npm test`

Tests currently need file called `test_config.js` at the root of the project. This file should export the API keys like this:
```
module.exports = {
    APP_ID: 'a',
    APP_KEY: 'b',
    MEDIA_DECRYPT_KEY: 'c'
};
```

---
_Source: https://npm.io/package/yleapi · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
