mugshot-js
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

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

Package Sidebar

Install

npm i mugshot-js

Weekly Downloads

8

Version

1.0.7

License

ISC

Unpacked Size

24.2 kB

Total Files

9

Last publish

Collaborators

  • jihantoro