# @decthings/api-client

> Official JavaScript API client for Decthings

Latest version **0.5.15** (published 2024-11-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @decthings/api-client
pnpm add @decthings/api-client
yarn add @decthings/api-client
bun add @decthings/api-client
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.15 |
| Published | 2024-11-25 |
| First published | 2020-09-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 669.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Decthings |
| Maintainers | viktorw |

## Links

- npm: https://www.npmjs.com/package/@decthings/api-client
- Repository: https://github.com/decthings/api-client-js
- Homepage: https://github.com/decthings/api-client-js#readme
- Issues: https://github.com/decthings/api-client-js/issues
- npm.io page: https://npm.io/package/@decthings/api-client

## Dependencies (3)

- [ws](https://npm.io/package/ws.md) ^8.16.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.7.0
- [@types/node](https://npm.io/package/@types/node.md) ^20

## Recent versions

- 0.5.15 (latest) — 2024-11-25
- 0.5.14 — 2024-11-22
- 0.5.13 — 2024-11-16
- 0.5.12 — 2024-11-16
- 0.5.11 — 2024-11-09
- 0.5.10 — 2024-10-24
- 0.5.9 — 2024-10-10
- 0.5.8 — 2024-10-07
- 0.5.7 — 2024-10-06
- 0.5.6 — 2024-09-25
- 0.5.5 — 2024-09-22
- 0.5.4 — 2024-05-17
- 0.5.3 — 2024-04-13
- 0.5.2 — 2024-04-08
- 0.5.1 — 2024-04-05
- … 11 more at https://npm.io/package/@decthings/api-client/versions

## README

<img src="https://decthings.com/logo.png" alt="decthings logo" width="33%" />

## Decthings API-client

[![npm version](https://badge.fury.io/js/@decthings%2Fapi-client.svg)](https://badge.fury.io/js/@decthings%2Fapi-client)

[Decthings](https://decthings.com) is a cloud-based API for artificial intelligence and machine learning. This package is officially supported by Decthings.

`npm install @decthings/api-client`

Can be used either in the browser or in Node.js.

---
#### Documentation

Documentation for this package is available [here](https://decthings.com/reference/javascript).

---

With Decthings, you can create AI models that run in the cloud. Then, use an API client to send input data and receive the output.

#### Example

```typescript
import * as fs from 'fs';
import { DecthingsClient, Data, DataElement } from '@decthings/api-client';

// Read image and convert to base64 data
const imageData = fs.readFileSync('/path/to/image.png');

// Create a client which will communicate with the server
const decthingsClient = new DecthingsClient();

// This is the ID for the Midas depth estimation model
const modelId = "20712947-6b2f-49f4-b2ff-8b9204971fa3";

// Construct an array containing the input data
const data = new Data([DataElement.image('png', imageData)]);

// Provide the modelId and input data to the evaluate function
decthingsClient.model.evaluate(modelId, [{ name: 'input', data }]).then(response => {
    if (response.error) {
        // The evaluation failed to start..
        console.log('The evaluation failed to start', response.error);
    }
    else if (response.result.failed) {
        // The evaluation was started but failed to complete..
        console.log('The evaluation failed to complete', response.result.failed);
    }
    else if (response.result.failed) {
        // success!
        console.log(response.result.success);
    }
})
```

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