# mugshot-js

> Javascript/Typescript SDK for Mugshot.dev API

Latest version **1.0.7** (published 2024-02-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install mugshot-js
pnpm add mugshot-js
yarn add mugshot-js
bun add mugshot-js
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2024-02-21 |
| First published | 2024-02-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 23.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | codenoid |
| Maintainers | jihantoro |
| Keywords | face-recognition, recognition, face, mugshot |

## Links

- npm: https://www.npmjs.com/package/mugshot-js
- npm.io page: https://npm.io/package/mugshot-js

## Recent versions

- 1.0.7 (latest) — 2024-02-21
- 1.0.6 — 2024-02-21
- 1.0.5 — 2024-02-21
- 1.0.4 — 2024-02-21

## README

# mugshot-js

The `mugshot-js` library provides a JavaScript/TypeScript SDK for interfacing with the [Mugshot.dev](https://mugshot.dev) API, allowing easy integration of face recognition capabilities into your web applications.

## Features

- Add faces to Mugshot.dev for recognition.
- Search for faces using uploaded images.
- Delete faces from Mugshot.dev.

## Installation

You can install `mugshot-js` using npm or yarn:

```bash
npm install mugshot-js
```

or

```bash
yarn add mugshot-js
```

## Usage

### Using the library in browser

```javascript
import {MugshotClient} from 'mugshot-js';

const client = new MugshotClient('YOUR_API_KEY');

document
	.getElementById('fileInput')
	.addEventListener('change', async function (event) {
		const file = event.target.files[0];
		const metadata = {name: 'John Doe'};

		try {
			const response = await client.addFace(file, metadata);
			console.log(response);
		} catch (error) {
			console.error(error);
		}
	});
```

### Using the library in Edge Environment

```javascript
import {MugshotClient} from 'mugshot-js';

const client = new MugshotClient('YOUR_API_KEY');

const payload = await request.formData();
const file = payload.get('image');
const metadata = {name: 'John Doe'};

try {
	const response = await client.addFace(file, metadata);
	console.log(response);
} catch (error) {
	console.error(error);
}
```

### Using the library with NodeJS

```javascript
import {MugshotClient} from 'mugshot-js';

const client = new MugshotClient('YOUR_API_KEY');

const payload = await request.formData();
const file = fs.openAsBlob('person-image.jpg');
const metadata = {name: 'John Doe'};

try {
	const response = await client.addFace(file, metadata);
	console.log(response);
} catch (error) {
	console.error(error);
}
```

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