npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

emx-shoppable-sdk-js

v1.0.12

Published

JavaScript SDK for Shoppable and Face Recognition APIs

Readme

emx-shoppable-sdk-js

A JavaScript SDK for interacting with:

✅ Player Description API ✅ Shoppable Item API ✅ Face Recognition API

This SDK provides simple AWS-style function calls using callbacks, with built-in error codes, logging, and support for custom error messages.

✅ Installation

npm install emx-shoppable-sdk-js


✅ Usage

How to import and use in code

const { EmxbeSDK } = require('emx-shoppable-sdk-js');

// Get Player Description EmxbeSDK.getPlayerDescription('dale steyn', (err, data) => { if (err) console.error('Error:', err); else console.log('Player Data:', data); });

// Get Shoppable Item EmxbeSDK.getShoppableItem('virat kohli', (err, data) => { if (err) console.error('Error:', err); else console.log('Shoppable Item:', data); });

// Face Recognition EmxbeSDK.recognizeFace('', (err, data) => { if (err) console.error('Error:', err); else console.log('Face Recognition Result:', data); });


✅ Test After Install

mkdir sdk-test cd sdk-test npm init -y npm install emx-shoppable-sdk-js

Create test.js:

const { EmxbeSDK } = require('emx-shoppable-sdk-js');

EmxbeSDK.getPlayerDescription('dale steyn', (err, data) => { console.log(err || data); });

Run:

node test.js

Error Codes Reference

| Code | Category | Short Code | Description | |-------|--------------------|------------------------------------|--------------------------------------------------------------------| | 1001 | Generic | ERR_API | API Error – Issue with API response | | 1002 | Generic | ERR_NETWORK | Network Error – No response received from server | | 1003 | Generic | ERR_UNKNOWN | Unexpected Error – Something went wrong | | 2001 | Player API | ERR_PLAYER_NAME_REQUIRED | Player name is required – Parameter "name" cannot be empty | | 2002 | Player API | ERR_PLAYER_NOT_FOUND | Player not found on Wikipedia | | 2003 | Player API | ERR_PLAYER_RATE_LIMIT | Rate limit exceeded on Wikipedia API | | 2004 | Player API | ERR_PLAYER_SERVICE_UNAVAILABLE | Wikipedia API unavailable | | 2005 | Player API | ERR_PLAYER_BAD_GATEWAY | Wikipedia API URL unreachable or invalid | | 3001 | Shoppable API | ERR_ITEM_NAME_REQUIRED | Search string is required | | 3002 | Shoppable API | ERR_SERP_API_KEY_MISSING | Missing SERP API key in environment | | 3003 | Shoppable API | ERR_SHOPPING_NOT_FOUND | No shopping results found | | 3004 | Shoppable API | ERR_SHOPPING_RATE_LIMIT | Rate limit exceeded on SERP API | | 3005 | Shoppable API | ERR_SHOPPING_SERVICE_UNAVAILABLE | SERP API service unavailable | | 3006 | Shoppable API | ERR_SHOPPING_BAD_GATEWAY | SERP API URL unreachable or invalid | | 1001* | Face Recognition | ERR_FACE_NO_IMAGE | No image provided | | 2001* | Face Recognition | ERR_FACE_DETECTION_FAILED | Face detection failed | | 2002* | Face Recognition | ERR_FACE_IMAGE_INCOMPATIBLE | Incompatible image format | | 2003* | Face Recognition | ERR_FACE_NO_FACE_DETECTED | No face detected | | 2004* | Face Recognition | ERR_FACE_NO_ENCODINGS | No face encodings found | | 3001* | Face Recognition | ERR_FACE_NO_MATCHING_PLAYER | No matching player found | | 404 | Face Recognition | ERR_FACE_PROFILE_NOT_FOUND | Cricbuzz profile link not found | | 500 | Face Recognition | ERR_FACE_PROFILE_SECTION_MISSING | Player profile section not found on Cricbuzz | | 5001 | Face Recognition | ERR_FACE_VIDEO_FETCH_FAILED | Failed to fetch videos | | 9001 | Face Recognition | ERR_FACE_LIBRARY_ERROR | face_recognition library error | | 9002 | Face Recognition | ERR_FACE_INTERNAL_SERVER_ERROR | Internal server error |

✅ Setting Custom Error Messages

 You can customize error codes and messages dynamically using setErrorCode():

const { setErrorCode, getErrorCodes } = require('emx-shoppable-sdk-js/utils/errorCodes');

// Customize Player API error
setErrorCode('ERR_PLAYER_NOT_FOUND', 9999, 'Custom message: Player data missing');

// Customize Shoppable API error
setErrorCode('ERR_SHOPPING_NOT_FOUND', null, 'Custom message: No items found');

// Customize Face Recognition error
setErrorCode('ERR_FACE_NO_IMAGE', 8888, 'Custom message: Please provide an image');

// Verify updates
console.log(getErrorCodes());

✅ After this, when the SDK encounters these errors, it will return your custom message and code.

 **NOTE**: Based on the error returned by the API , Search that particular errors "Short Code" from the above error list and then pass it in the setErrorCode() Function to Customize the Error Codes to your preference.

 **Example**: Suppose while using the SDK, Error returned by FaceRecognize API is :  
              {
                "error": "Internal server error: list index out of range",
                "error_code": 9002
              }

  Find this particular ERROR CODE and MESSAGE in the Error Codes Reference and get its SHORT CODE and then use that along with a customized Error Message and Error Code of your Preference, Like Below.

              setErrorCode("ERR_FACE_INTERNAL_SERVER_ERROR", 6699, "Custom message: Please dont waste my time...");

  Then this particular Customized Message will be rendered.

  The Same Applies to the other TWO API's.

✅ Example Error Object Returned by SDK:

{
  "code": 9999,
  "message": "Custom message: Player data missing",
  "details": { "error": "Invalid player name" }
}

{
  "code": null,
  "message": "Custom message: No items found",
  "details": { "error": "Custom message: No items found" }
}

{
  "code": 8888,
  "message": "Custom message: Please provide an image",
  "details": { "error": "Custom message: No image provided" }
}

✅ React Integration Example

 Here’s how you can integrate the SDK in a React component and display custom error messages in the UI:

import React, { useRef, useState, useEffect } from "react";
import "./VideoPlayer.css";
import { EmxbeSDK } from "emx-shoppable-sdk-js";
import { setErrorCode, getErrorCodes } from "emx-shoppable-sdk-js/utils/errorCodes";

const VideoPlayer = () => {
  const videoRef = useRef(null);
  const [errorMessage, setErrorMessage] = useState("");

  // -------------------------------------------------
  // CUSTOM ERROR CODES 
  // -------------------------------------------------
  useEffect(() => {
    // Face recognition errors
    setErrorCode("ERR_FACE_INTERNAL_SERVER_ERROR", 9966, "Custom message: Please provide suna");
    setErrorCode("ERR_FACE_NO_MATCHING_PLAYER", 7777, "Custom message: No matching player found in database");

    // Shoppable errors
    setErrorCode("ERR_SHOPPING_NOT_FOUND", 3553, "Custom message: No items found");

    console.log("Updated Error Codes:", getErrorCodes());

    if (videoRef.current) {
      videoRef.current.crossOrigin = "anonymous";
    }
  }, []);

  // -------------------------------------------------
  // FRAME CAPTURE (NEEDED FOR FACE RECOGNITION)
  // -------------------------------------------------
  const captureFrame = () => {
    const video = videoRef.current;
    if (!video) return null;

    const canvas = document.createElement("canvas");
    canvas.width = video.videoWidth;
    canvas.height = video.videoHeight;

    const ctx = canvas.getContext("2d");
    ctx.drawImage(video, 0, 0, canvas.width, canvas.height);

    return canvas.toDataURL("image/jpeg");
  };

  // -------------------------------------------------
  // ONLY SDK CALLS — FACE RECOG + STATS + VIDEOS
  // -------------------------------------------------
  const handleInfoClick = () => {
    setErrorMessage("");

    const image = captureFrame();
    if (!image) return;

    // 1️⃣ FACE RECOGNITION
    EmxbeSDK.recognizeFace("", (err, data) => {
      if (err) {
        setErrorMessage(`Face Recognition Error: ${err.message} (Code: ${err.code})`);
        return;
      }

      // 2️⃣ PLAYER DESCRIPTION
      EmxbeSDK.getPlayerDescription("//", (err, playerData) => {
        if (err) {
          setErrorMessage(`Player Description Error: ${err.message} (Code: ${err.code})`);
        }
      });

      // 3️⃣ SHOPPABLE ITEMS
      EmxbeSDK.getShoppableItem("mohanlal", (err, shopData) => {
        if (err) {
          setErrorMessage(`Shoppable Item Error: ${err.message} (Code: ${err.code})`);
        }
      });
    });
  };

  return (
    <div className="video-player-container">

      {/* VIDEO PLAYER */}
      <video ref={videoRef} className="video-player" controls>
        <source src="source.mp4" type="video/mp4" />
        Your browser does not support the video tag.
      </video>

      {/* INFO BUTTON */}
      <div className="info-icon" onClick={handleInfoClick}>i</div>

      {/* ERROR MESSAGE */}
      {errorMessage && (
        <div className="error-message">
          <p>{errorMessage}</p>
        </div>
      )}

    </div>
  );
};

export default VideoPlayer;

✅ This example:

  • Captures a video frame
  • Calls Face Recognition, Player Description, and Shoppable APIs
  • Displays custom error messages in the UI

✅ What Each Successful SDK Call Output Looks Like

  1. Face Recognition:
{
  "recognized_player": "tim_paine",
  "stats": {
  "error": "Player profile section not found on Cricbuzz."
},
  "videos": [
    {
      "channelTitle": "Star Sports",
      "thumbnail": "https://i.ytimg.com/vi/pfO64Is2fVA/hqdefault.jpg",
      "title": "2021 Sydney Test: Tim Paine & R. Ashwin's epic banter caught on the stump mic! | #AUSvINDonStar",
      "videoId": "pfO64Is2fVA"
    },
    {
      "channelTitle": "TwoLeftHands",
      "thumbnail": "https://i.ytimg.com/vi/FyOHZKEDhPg/hqdefault.jpg",
      "title": "The LUCKIEST AND UNLUCKIEST test CRICKET CAREER!? 😯",
      "videoId": "FyOHZKEDhPg"
    }
  ]
}
  1. Get Player Description:
{
  "name": "Tim Paine",
  "description": "Timothy David Paine is an Australian former cricketer and a former captain...",
  "image": {
    "thumbnail": "https://upload.wikimedia.org/wikipedia/commons/...",
    "original": "https://upload.wikimedia.org/wikipedia/commons/..."
  }
}
  1. Get Shoppable Item:
{
  "code": 200,
  "shopping_details": [
    {
      "price": "₹2,500",
      "title": "The Empuraan Eagle Ring",
      "source": "Vitra Jewellery",
      "delivery": "Free delivery",
      "position": 1,
      "thumbnail": "https://encrypted-tbn3.gstatic.com/...",
      "product_id": "10134496805831390726",
      "product_link": "https://www.google.com/search?ibp=oshop&q=mohanlal..."
    }
  ]
}

✅ Author & Company

Author: Akshay Saji
Company: L&T Technology Services


✅ This README includes: - Installation steps - Usage examples - Error codes table - Author & company info - Publish & test instructions