# freee-node

> freee api client for node.js

Latest version **1.0.0** (published 2017-10-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install freee-node
pnpm add freee-node
yarn add freee-node
bun add freee-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 | 1.0.0 |
| Published | 2017-10-26 |
| First published | 2017-10-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ymzkmct |
| Maintainers | ymzkmct |

## Links

- npm: https://www.npmjs.com/package/freee-node
- npm.io page: https://npm.io/package/freee-node

## Dependencies (1)

- [client-oauth2](https://npm.io/package/client-oauth2.md) ^4.1.0

## Recent versions

- 1.0.0 (latest) — 2017-10-26

## README

freee API Client for Node.js
====

[freee](https://www.freee.co.jp/)の公開APIのnode.js用クライアントです。ただし現時点ではAuthorization Code Flowのみに対応しています

## APIドキュメント

freeeのAPIのドキュメントは[こちら](https://secure.freee.co.jp/developers/api/doc)を参照してください

## Install
```
npm install freee-node --save
```

## Usage


```js
var Freee = require('freee-node')
var freee = new Freee({
    clientId: CLIENT_ID,
    clientSecret: CLIENT_SECRET,
    redirectUri: CALLBACK_URI
});
```

### access token保存まで

expressを利用したWebサーバで、authorization codeを取得するためにURLにリダイレクトするケースと、access tokenを取得する方法についてのサンプルコードです。oauth2の処理は[js-client-oauth2](https://github.com/mulesoft/js-client-oauth2/)のライブラリに大きく依存しています。

```js
app.get('/freee', function(req, res) {
    //認可コード取得用のURLに遷移する
    res.redirect(freee.getUri())
})
app.get('/freee/callback', function(req, res) {
    //認可コードからアクセストークンを取得する
    freee.getToken(req.originalUrl).then(function(token) {
        // token.accessTokenやtoken.refreshTokenを保存する
    })
})
```

### freee APIを利用する
```js
freee.api.get('/api/1/users/me', {companies: true}).then(function(res) {
    console.log(res)
})
freee.api.get('/api/1/account_items', {company_id: company_id}).then(function(res) {
    console.log(res)
})
freee.api.post('/api/1/items', {
    company_id: company_id,
    name: 'ひんもーく',
    shortcut1: 'hnmk',
    shortcut2: 'hinmoku'
}).then(function(res) {
    console.log(res)
})
```


## Licence

[MIT](https://choosealicense.com/licenses/mit/)

## Author

[ymzkmct](https://github.com/ymzkmct)

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