# @tuyapi/openapi

> 🚪 a wrapper for Tuya's OpenAPI

Latest version **1.3.0** (published 2021-05-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tuyapi/openapi
pnpm add @tuyapi/openapi
yarn add @tuyapi/openapi
bun add @tuyapi/openapi
```

## 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.3.0 |
| Published | 2021-05-13 |
| First published | 2020-01-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Max Isom |
| Maintainers | codetheweb, tuyapi-ci |

## Links

- npm: https://www.npmjs.com/package/@tuyapi/openapi
- Repository: https://github.com/TuyaAPI/openapi
- Homepage: https://github.com/TuyaAPI/openapi#readme
- Issues: https://github.com/TuyaAPI/openapi/issues
- npm.io page: https://npm.io/package/@tuyapi/openapi

## Dependencies (1)

- [got](https://npm.io/package/got.md) ^10.2.2

## Recent versions

- 1.3.0 (latest) — 2021-05-13
- 1.2.4 — 2021-02-04
- 1.2.3 — 2021-01-28
- 1.2.2 — 2021-01-27
- 1.2.1 — 2021-01-19
- 1.2.0 — 2020-06-27
- 1.1.0 — 2020-05-05
- 1.0.0 — 2020-04-12
- 0.2.0 — 2020-02-14
- 0.1.3 — 2020-01-31
- 0.1.2 — 2020-01-26
- 0.1.0 — 2020-01-20

## README

# A TypeScript wrapper for Tuya's [OpenAPI](https://docs.tuya.com/en/iot/open-api/quick-start/solution-overview)

[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) [![Build Status](https://travis-ci.com/TuyaAPI/openapi.svg?branch=master)](https://travis-ci.com/TuyaAPI/openapi)

## Why?

There is another package called `@tuyapi/cloud`.  Why does this one exist?

The other package deals with Tuya's 'mobile' API, which has limited usefulness as Tuya seems to be phasing it out.

This package instead uses their 'OpenAPI', the solution that they recommend third-party applications use.

## Installation

`npm i @tuyapi/openapi`

## Example Usage

(The `schema` value is your unique app ID from the Tuya console.)

```javascript
const OpenAPI = require('@tuyapi/openapi');

const api = new OpenAPI({key: '10101010', secret: '1010101010', schema: '10101010'});

(async () => {
  // Must be called before any other operations to get auth token
  await api.getToken();

  const uid = await api.putUser({
    countryCode: '1',
    username: 'your-username',
    password: 'your-password',
    usernameType: 1});

  console.log(uid);

  const token = await api.getDeviceToken({uid, timezone: 'America/Chicago'});

  console.log(token);

  console.log(await api.getDevicesByToken('EkjQjlbo'));
})();
```

## [Docs](docs/classes/api.openapi.md)

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