1.0.7 • Published 3 months ago

mugshot-js v1.0.7

Weekly downloads
2
License
ISC
Repository
-
Last release
3 months ago

mugshot-js

The mugshot-js library provides a JavaScript/TypeScript SDK for interfacing with the 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:

npm install mugshot-js

or

yarn add mugshot-js

Usage

Using the library in browser

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

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

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);
}
1.0.7

3 months ago

1.0.6

3 months ago

1.0.5

3 months ago

1.0.4

3 months ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago