# fly-api

> Fly.io API wrapper for simplifying REST calls.

Latest version **0.1.0** (published 2017-07-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install fly-api
pnpm add fly-api
yarn add fly-api
bun add fly-api
```

## 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.0 |
| Published | 2017-07-19 |
| First published | 2017-07-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Brian Woodward |
| Maintainers | doowb |
| Keywords | api, fly |

## Links

- npm: https://www.npmjs.com/package/fly-api
- Repository: https://github.com/doowb/fly-api
- Issues: https://github.com/doowb/fly-api/issues
- npm.io page: https://npm.io/package/fly-api

## Dependencies (2)

- [superagent](https://npm.io/package/superagent.md) ^3.5.2
- [extend-shallow](https://npm.io/package/extend-shallow.md) ^2.0.1

## Recent versions

- 0.1.0 (latest) — 2017-07-19

## README

# fly-api [![NPM version](https://img.shields.io/npm/v/fly-api.svg?style=flat)](https://www.npmjs.com/package/fly-api) [![NPM monthly downloads](https://img.shields.io/npm/dm/fly-api.svg?style=flat)](https://npmjs.org/package/fly-api)  [![NPM total downloads](https://img.shields.io/npm/dt/fly-api.svg?style=flat)](https://npmjs.org/package/fly-api)

> Fly.io API wrapper for simplifying REST calls.

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save fly-api
```

Install with [yarn](https://yarnpkg.com):

```sh
$ yarn add fly-api
```

## Usage

```js
var Fly = require('fly-api');
```

## API

### [Fly](index.js#L18)

Create a new Fly instance using the given options.

**Params**

* `options` **{Object}**: Options for setting authentication token and api url.
* `options.token` **{String}**: Authentication token for fly.io api.
* `options.url` **{String}**: fly.io api url. Defaults to (https://fly.io/api/v1/)

**Example**

```js
var fly = new Fly({token: 'xxxx'});
```

### [.get](index.js#L51)

Send a GET request to the specified `path` at the fly.io api url.

**Params**

* `path` **{String}**: Path to use after the api url
* `options` **{Object}**: Options
* `cb` **{Function}**: Callback function that takes an `err` and `result` parameters.

**Example**

```js
fly.get('sites/doowb/hostnames', {}, function(err, result) {
  if (err) {
    console.error(err);
    return;
  }
  console.log(result);
  //=> {
  //=>   "data": {
  //=>     "attributes": {
  //=>        "hostname": "foo.doowb.com"
  //=>     }
  //=>   }
  //=> }
});
```

### [.post](index.js#L90)

Send a POST request to the specified `path` at the fly.io api url.

**Params**

* `path` **{String}**: Path to use after the api url
* `data` **{Object}**: The payload to send in the post.
* `cb` **{Function}**: Callback function that takes an `err` and `result` parameters.

**Example**

```js
var options = {
  data: {
    attributes: { hostname: 'bar.doowb.com' }
  }
};

fly.post('sites/doowb/hostnames', options, function(err, result) {
  if (err) {
    console.error(err);
    return;
  }
  console.log(result);
  //=> {
  //=>   "data": {
  //=>     "attributes": {
  //=>        "hostname": "bar.doowb.com"
  //=>     }
  //=>   }
  //=> }
});
```

## About

### Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.

### Building docs

_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_

To generate the readme, run the following command:

```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```

### Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

```sh
$ npm install && npm test
```

### Author

**Brian Woodward**

* [github/doowb](https://github.com/doowb)
* [twitter/doowb](https://twitter.com/doowb)

### License

Copyright © 2017, [Brian Woodward](https://doowb.com).
Released under the [MIT License](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 19, 2017._

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