An open API service indexing awesome lists of open source software.

https://github.com/oknehsorod/mono-api


https://github.com/oknehsorod/mono-api

Last synced: 7 months ago
JSON representation

Awesome Lists containing this project

README

          

# MonoAPI


mono api

This is typed and tested wrapper for MonoAPI by Monobank

## Token Creation

To create MonoAPI token you need to visit Official [MonoAPI](https://api.monobank.ua/index.html 'MonoAPI') page and create your token.

## Install

| Package Manager | Script |
| :-------------: | :---------------------: |
| NPM | npm i mono-api |
| YARN | yarn add npm i mono-api |
| PNPM | pnpm add mono-api |

## Examples

**JavaScript/TypeScript:**

```javascript
const monoAPI = new MonoAPI('');

const clientInfo = await monoAPI.fetchClientInfo();

const today = new Date();
const oneWeekAgo = new Date(today);
oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);

const statements = await monoAPI.fetchStatements({
from: oneWeekAgo,
to: today,
});
```

## Documentation
**Fetch Client Information**
```typescript
import { MonoAPI, MonobankClientInfo } from 'mono-api';

const monoAPI = new MonoAPI('');

const clientInfo: MonobankClientInfo = await monoAPI.fetchClientInfo();

console.log('ClientInfo: ', clientInfo);
```

**Fetch Statements**
```typescript
import { MonoAPI, MonobankStatements } from 'mono-api';

const monoAPI = new MonoAPI('');

const today = new Date();
const oneWeekAgo = new Date(today);
oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);

const statements: MonobankStatements = await monoAPI.fetchStatements({
account: '0' // Or id of acccount
from: oneWeekAgo,
to: today
});

console.log('Statements: ', statements);
```
**Fetch Currencies**
```typescript
import { MonoAPI, MonobankCurrencies } from 'mono-api';

const monoAPI = new MonoAPI(''); // For this method API Token can be omitted

const currencies: MonobankCurrencies = await monoAPI.fetchCurrencies();

console.log('Currencies: ', currencies);
```

## Suggestion

If you want to offer me to add new methods to this API, feel free to create an issue.