# teamtrees-api

> a TeamTrees.org unofficial api to get the top, recent, and total donations.

Latest version **1.2.0** (published 2019-11-04) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2019-11-04 |
| First published | 2019-10-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 20.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Jacxk |
| Maintainers | jacxk |
| Keywords | teamtrees, #teamtrees, treelon, teamtrees-api, teamtrees.org |

## Links

- npm: https://www.npmjs.com/package/teamtrees-api
- Repository: https://github.com/Jacxk/TeamTrees-API
- Homepage: https://teamtrees.org/
- Issues: https://github.com/Jacxk/TeamTrees-API/issues
- npm.io page: https://npm.io/package/teamtrees-api

## Dependencies (1)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0

## Recent versions

- 1.2.0 (latest) — 2019-11-04
- 1.1.1 — 2019-11-02
- 1.1.0 — 2019-11-01
- 1.0.1 — 2019-10-31
- 1.0.0 — 2019-10-31

## README

# TeamTrees-API

[![NPM](https://nodei.co/npm/teamtrees-api.png)](https://www.npmjs.com/package/teamtrees-api)

TeamTrees-API is the un-official API for [TeamTrees.org](https://teamtrees.org/)\
With this package you can get information such as the amount of money donated, recent donations
and see if Treelon (AKA Elon Musk) is #1.

If you haven't donated yet, please do, and share the website. We gotta hit the 20M by 2020.

I donated and I got proof 👀:\
![proof](https://i.imgur.com/PfdZeti.png)

## Usage
You can find the file test [here](https://github.com/Jacxk/TeamTrees-API/blob/master/test.js).\
This package comes with a rate limiter and a cache system so you dont break the website by making 1,000 requests.
You can disable it but I don't recommend it.

### Options:
```js
// they are all optional
{
  rateLimit: true // enable rate limiter
  cache: {
    enable: true, // enable the cache syste,
    duration: 5 // time to hold the data in minutes
  }
}
```

### Initialize:
```js
const {TeamTrees} = require('teamtrees-api');
const teamTrees = new TeamTrees(/* options */);
```

### Methods:
```js
// Get all total donation amount
teamTrees.getTotalTrees(true).then(console.log); // 10,048,199
teamTrees.getTotalTrees(false).then(console.log); // 10048199

// Get the most recent donations
teamTrees.getMostRecent().then(console.log);

/* OutPut
[
  ...
  {
    "name": 'yoy0n',
    "trees": '20',
    "message": 'Giving back to mother earth!',
    "date": 2019-10-31T03:43:14.807Z,
    "img": 'https://teamtrees.org/images/icon-badge-leaf-2.svg'
  }
  ...
]
*/

// Get the top donations (where Elon Musk is)
teamTrees.getMostTrees().then(console.log);

/* OutPut
[
  ...
  {
    "name": 'Elon Musk',
    "trees": '1,000,000',
    "message": 'For Treebeard',
    "date": 2019-10-30T00:00:00.000Z,
    "img": 'https://teamtrees.org/images/icon-badge-earth.svg'
  }
  ...
]
*/

// I suck at naming btw
// Get the days left and trees left
// Thanks to @subgap (https://twitter.com/subgap) for the idea
teamTrees.getLeft().then(console.log)

/* OutPut
{
  "daysLeft": 60,
  "treesLeft": {
    "amount": {
      "fixed": '8,602,253',
      "value": 8602253
    },
    "percent": '56.99'
  }
*/
```

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