JSPM

mugshot-js

1.0.7
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 1
    • Score
      100M100P100Q32081F
    • License ISC

    Javascript/Typescript SDK for Mugshot.dev API

    Package Exports

    • mugshot-js
    • mugshot-js/dist/client.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mugshot-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

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