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 🙏

© 2024 – Pkg Stats / Ryan Hefner

lykdat

v0.0.6

Published

Official JavaScript SDK for Lykdat API (https://solutions.lykdat.com/)

Downloads

10

Readme

Lykdat JavaScript SDK

Official JavaScript SDK for Lykdat API

NOTE: This library is suited for a Web Browser environment only and will not work in a Node JS environment.

Install

npm install lykdat

Usage

Two primary functionalities are offered by this SDK: Image Search and Product Alerts

Image Search

The Image Search function does all the UI related heavy-lifting for you, thereby relieving you of the stress. All you need to do is invoke the function and it renders a search button at the bottom right corner of your page. Once a search is completed, it also renders the search results UI for you.

The Image Search function can be used like so:

import * as lykdat from 'lykdat'

window.addEventListener('load', () => {
    lykdat.initImageSearchUI({
        publishableApiKey: 'YOUR_API_KEY_HERE',
        catalogName: 'YOUR_CATALOG_NAME',
    })
})

If you'd like to use your own custom search button, just pass the css selector to your button so the appropriate event handler can be attached to it:

import * as lykdat from 'lykdat'

window.addEventListener('load', () => {
    lykdat.initImageSearchUI({
        publishableApiKey: 'YOUR_API_KEY_HERE',
        catalogName: 'YOUR_CATALOG_NAME',
        triggerSelector: '#my-button-id'
    })
})

The Image Search UI looks something like this when the trigger button is clicked:

Image search

Text Search

The Text Search API enables you do a full text search for Products in your Catalog. You can filter and sort by fields. The result also returns facets which can be important for eCommerce Search result pages. This functionality does not currently offer any UI related features. The Text Search function can be used like so:

import * as lykdat from 'lykdat'

const config = {
    publishableApiKey: 'YOUR_API_KEY_HERE',
    catalogName: 'YOUR_CATALOG_NAME',
}

const options = {
    genders: ['male', 'unisex'],
    colors: ['red', 'blue', 'navy']
}

lykdat.searchText('furry shorts', config, options).then((result) => {
    console.log(result.products)
    console.log(result.pagination)
    console.log(result.facets)
}).catch((err) => {
    // handle error
})

Product Alert

The Product Alert API offers both UI and non-UI functionality.

Price Alerts

With the Price Alerts function your users can subscribe to know when the price of a Product drops. The function can be used like so:

import * as lykdat from 'lykdat'

const config = {
    publishableApiKey: 'YOUR_API_KEY_HERE',
    websiteName: 'mywebsite'
}
const email = '[email protected]'
const productUrl = 'https://mywebsite.url/product/url'

lykdat.subscribeToPriceAlert(config, email, productUrl).then(() => {
    console.log('success')
}).catch((err) => {
    // handle error
})

In-stock Alerts

With the In-stock Alerts function, your users can subscribe to know when a currently unavailable product is back in-stock. The function can be used like so:

import * as lykdat from 'lykdat'

const config = {
    publishableApiKey: 'YOUR_API_KEY_HERE',
    websiteName: 'mywebsite'
}
const email = '[email protected]'
const productUrl = 'https://mywebsite.url/product/url'

lykdat.subscribeToInStockAlert(config, email, productUrl).then(() => {
    console.log('success')
}).catch((err) => {
    // handle error
})

In-stock Alerts UI

This Function Attaches a Form UI to the dom. With this Form, users of your website can subscribe to be notified when the related product is in-stock. This functionality removes the need for you to add any UI related code by doing it all for you.

The UI Finction can be used like so:

import * as lykdat from 'lykdat'

window.addEventListener('load', () => {
    lykdat.initInStockAlertUI({
        publishableApiKey: 'YOUR_API_KEY_HERE',
        websiteName: 'YOUR_WEBSITE_NAME',
        targetSelector: '#back-in-stock-container'
    })
})

The UI looks something like this when loaded to your website:

In Stock Alerts Form

Product Extraction

The Product Extraction function extracts the details of any Product (name, price, currency, images, availability) from its Product URL.

The function can be used like so:

import * as lykdat from 'lykdat'

const config = {
    publishableApiKey: 'YOUR_API_KEY_HERE',
}

const productUrl = 'https://mywebsite.url/product/url'

lykdat.extractProduct(config, productUrl).then((extraction) => {
    if (extraction.product) {
        console.log('success', extraction.product)
    } else {
        console.log('product could not be extracted :/')
    }
}).catch((err) => {
    // handle error
})

Examples

To see how the SDK is used in code examples, please the examples folder