# sam-node

> SAM API wrapper

Latest version **2.0.2** (published 2016-11-22) · 0 weekly downloads

## Install

```sh
npm install sam-node
pnpm add sam-node
yarn add sam-node
bun add sam-node
```

## 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 | 2.0.2 |
| Published | 2016-11-22 |
| First published | 2014-08-05 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= v0.10.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | SAM |
| Maintainers | samdesk |

## Links

- npm: https://www.npmjs.com/package/sam-node
- Repository: https://github.com/SAMdesk/sam-node
- Issues: https://github.com/SAMdesk/sam-node/issues
- npm.io page: https://npm.io/package/sam-node

## Dependencies (2)

- [when](https://npm.io/package/when.md) ~2.4.0
- [async](https://npm.io/package/async.md) ^1.5.0

## Recent versions

- 2.0.2 (latest) — 2016-11-22
- 2.0.1 — 2015-12-22
- 2.0.0 — 2015-12-22
- 1.0.0 — 2015-07-08
- 0.0.4 — 2014-08-05
- 0.0.3 — 2014-08-05
- 0.0.2 — 2014-08-05
- 0.0.1 — 2014-08-05

## README

# SAM Node [![Build Status](https://travis-ci.org/SAMdesk/sam-node.png?branch=master)](https://travis-ci.org/SAMdesk/sam-node)

## Overview

This repo contains a node middleware to simplify the usage of the SAM API.

## Installation

`npm install sam-node`

## Documentation

Up to date API Documentation can be found [here](https://api.samdesk.io).

## API Overview

Every resource is accessed via your `sam` instance:

```js
var sam = require('sam-node')({ api_key: '{API_KEY}' });
// sam.{ RESOURCE_NAME }.{ METHOD_NAME }
```

Every resource method accepts an optional callback as the last argument:

```js
sam.stories.fetch(
    storyId,
    function(err, story) {
        //handle response
    }
);
```

Additionally, every resource method returns a promise, so you don't have to use the regular callback:

```js
sam.stories.fetch(
    storyId
).then(function(story) {
    // handle successful response
}, function(err) {
    // handle error
});
```

### Available resources & methods

*Where you see `params` it is a plain JavaScript object, e.g. `{ email: 'foo@example.com' }`*

 * account
  * `fetch()`
  * `users()`
 * assets
  * `create(storyId, params)`
  * `fetch(storyId, assetId[, params])`
  * `list(storyId[, params])`
 * stories
  * `create(params)`
  * `fetch(storyId[, params])`
  * `delete(storyId)`
  * `list([params])`
  * `fetchAsset(storyId, assetId[, params])`
  * `listAssets(storyId[, params])`
 * upload
  * `upload(params)`
  * `start(params)`
  * `append(mediaId, params)`
  * `complete(mediaId)`
 * user
  * `fetch()`

## Configuration

 * `sam.setAuth({ api_key: '{API_KEY}' });`
 * `sam.setTimeout(20000); // in ms` (default is node's default: `120000ms`)

## Author

Officially maintained by SAM.

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