# storyblok-node-client

> Storyblok API interface for Node.js (4+)

Latest version **1.0.2** (published 2018-03-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install storyblok-node-client
pnpm add storyblok-node-client
yarn add storyblok-node-client
bun add storyblok-node-client
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-03-20 |
| First published | 2017-05-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alexander Feiglstorfer |
| Maintainers | delooks, dominikangerer |
| Keywords | storyblok |

## Links

- npm: https://www.npmjs.com/package/storyblok-node-client
- Repository: https://github.com/storyblok/storyblok-node-client
- Homepage: https://github.com/storyblok/storyblok-node-client#readme
- Issues: https://github.com/storyblok/storyblok-node-client/issues
- npm.io page: https://npm.io/package/storyblok-node-client

## Dependencies (3)

- [request](https://npm.io/package/request.md) ^2.79.0
- [object-hash](https://npm.io/package/object-hash.md) ^1.1.8
- [memory-cache](https://npm.io/package/memory-cache.md) ^0.1.6

## Recent versions

- 1.0.2 (latest) — 2018-03-20
- 1.0.1 — 2017-12-13
- 1.0.0 — 2017-05-27

## README

# Official Storyblok Node.js client

This client will provide you some helpers for the Storyblok publishing API.

This repository has been inspired by https://github.com/schornio/node-storyblok. Big thanks to [Thomas Schorn](https://github.com/schornio) for this awesome package.

## Install

```
npm install storyblok-node-client
```

## Usage

### Class `Storyblok`

**Parameters**

- `config` Object
  - `privateToken` String, The private token you can find in your space dashboard at https://app.storyblok.com
  - `cache` Object
    - `type` String, `filesystem` or `memory`
    - `path` String, required if you use `filesystem` as type
- (`endpoint` optional)

**Example**

```javascript
// 1. Require the Storyblok node client
const StoryblokClient = require('storyblok-node-client');

// 2. Initialize the client with the private key 
// from your space dashboard at https://app.storyblok.com
let Storyblok = new StoryblokClient({
  privateToken: 'xf5dRMMjltLzKOcNgMaU9Att'
});
```

### Activating request cache

The Storyblok nodejs client comes with a caching mechanism.
When initializing the Storyblok client you can define a cache provider for caching the requests on the filesystem or in memory.
To clear the cache you can call `Storyblok.flushCache();`.

```javascript
// For a filesystem cache the path parameter is mandatory
let Storyblok = new StoryblokClient({
  privateToken: 'xf5dRMMjltLzKOcNgMaU9Att',
  cache: {
    type: 'filesystem',
    path: './public/datastorage/'
  }
});

// For the memory cache only the type paramter is required
let Storyblok = new StoryblokClient({
  privateToken: 'xf5dRMMjltLzKOcNgMaU9Att',
  cache: {
    type: 'memory'
  }
});
```

### Method `Storyblok#get`

**Parameters**
- `[return]` Promise, Object `response`
- `path` String, Path (can be `stories`, `stories/*`, `tags`, `datasources`, `links`)
- `options` Object, Options can be found in the [API documentation](https://www.storyblok.com/docs/Delivery-Api/get-a-story).

**Example**

```javascript
Storyblok
  .get('stories/home', {
    version: 'draft'
  })
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });
```

### Method `Storyblok#flushCache`

**Parameters**

- `[return]` Object, returns the Storyblok client

**Example**

```javascript
Storyblok.flushCache();
```

## Contribution

Fork me on [Github](https://github.com/storyblok/storyblok-node-client)

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