# mcpetrade-api

> API Wrapper для взаимодействия с mcpetrade api

Latest version **1.0.1** (published 2021-02-18) · MIT license · 0 weekly downloads

## Install

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

## 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.1 |
| Published | 2021-02-18 |
| First published | 2021-02-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Pelemen |
| Maintainers | danya7423 |
| Keywords | mcpetrade, mcpetrade-api, апи, mcpetrade |

## Links

- npm: https://www.npmjs.com/package/mcpetrade-api
- Repository: https://github.com/pelemen228/mcpetrade-api-js-wrapper
- Homepage: https://github.com/pelemen228/mcpetrade-api-js-wrapper#readme
- Issues: https://github.com/pelemen228/mcpetrade-api-js-wrapper/issues
- npm.io page: https://npm.io/package/mcpetrade-api

## Recent versions

- 1.0.1 (latest) — 2021-02-18
- 1.0.0 — 2021-02-18

## README

# Mcpetrade API Wrapper
API Wrapper для взаимодействия с mcpetrade.com
## Подключение

``` js
const {
    MCPETrade
} = require('mcpetrade-api')
const mc = new MCPETrade({"shop": shopId, "server": serverId})
```

## Методы API
***createPayment*** - создать счет на оплату
| Параметр | Тип | Обязателен | Описание |
|--|--|--|--|
| productId | number | Да | ID продукта |
| username | string | Да | Ник пользователя |
| coupon | string | Нет | Скидочный купон |

**Пример**
``` js
async function createPayment() {
let payment = mc.createPayment(104252, 'test') 
console.log(payment) // { status: 'success', response: 'https://pay.mcpetrade.com?account=1234' }
}
createPayment().catch(console.error)
```

***getServers*** - получить все сервера привязанные к вашему магазину

**Пример**
``` js
async function getServers() {
let servers = mc.getServers() 
console.log(servers) // { status: 'success', response: [ { id: '124', name: 'Test' } ] }
}
getServers().catch(console.error)
```

***getServers*** - получить онлайн серверов привязанных к магазину

**Пример**
``` js
async function getOnline() {
let online = mc.getOnline() 
console.log(online) // { status: 'success', response: [{id: '123',name: 'Test',domain: '',port: '19132',online: true,numplayers: 130,maxplayers: 10000}]}
}
getOnline().catch(console.error)
```

***getProducts*** - получить список продуктов магазина
| Параметр | Тип | Обязателен | Описание |
|--|--|--|--|
| category | string | Нет | Категория продукта |

**Пример**
``` js
async function getProducts() {
let products = mc.getProducts() 
console.log(products)
}
getProducts().catch(console.error)
```

***getPaymentStatus*** - получить состояние счета (оплачен или нет)
| Параметр | Тип | Обязателен | Описание |
|--|--|--|--|
| billId | number | Да | ID счета |

**Пример**
``` js
async function getPaymentStatus() {
let payment = mc.getPaymentStatus(123) 
console.log(payment) // { status: 'success', response: { status: 'waiting' } }
}
getPaymentStatus().catch(console.error)
```

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