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

web-extract-data

v0.1.0

Published

A JavaScript package for extracting structured data from websites

Readme

Web Extract Data

A JavaScript package for extracting structured data from websites without writing a single HTML selector.

Web Extract Data provides native functions for each endpoint of the InstantAPI.ai Web Scraping API, making it easy to extract data from websites, find links, navigate through pagination, and scrape Google Search results.

Installation

npm install web-extract-data

Quick Start

const { WebExtractClient } = require('web-extract-data');

// Initialize the client with your InstantAPI.ai key
// Replace %% API_KEY %% with your API key from:
// https://web.instantapi.ai/#pricing-03-254921

const client = new WebExtractClient("%%API_KEY%%");

// You can modify the URL and data fields to extract in JSON format
client.scrape({
  url: "https://www.amazon.com.au/MSI-PRO-MP341CQW-UltraWide-Compatible/dp/B09Y19TRQ2",
  fields: {
    "monitor_name": "< The product name of the monitor. >",
    "brand": "< The brand or manufacturer name. >",
    "display_size_in_inches": "< Numeric only. >",
    "resolution": "< Example format: 1920x1080. >",
    "panel_type": "< Type of panel. >",
    "refresh_rate_hz": "< Numeric only. >",
    "aspect_ratio": "< Example format: 16:9. >",
    "ports": "< A comma-delimited list of available ports (e.g., HDMI, DisplayPort, etc.). >",
    "features": "< Key selling points or capabilities, comma-delimited (e.g., LED, Full HD, etc.). >",
    "price": "< Numeric price (integer or float). >",
    "price_currency": "< Price currency (3 character alphabetic ISO 4217). >",
    "review_count": "< Total number of customer reviews, numeric only. >",
    "average_rating": "< Float or numeric star rating (e.g., 4.3). >",
    "review_summary": "< A 50 words or less summary of all the written customer feedback. >"
  }
})
.then(result => {
  // Print the extracted data
  console.log(result);
})
.catch(error => {
  console.error("Error:", error.message);
});

API Reference

WebExtractClient

The main client class for interacting with the InstantAPI.ai Web Scraping API.

const client = new WebExtractClient(apiKey);
  • apiKey (string): Your InstantAPI.ai key.

Scrape Endpoint

Extract structured data from any webpage.

client.scrape({ url, fields })
  .then(result => console.log(result))
  .catch(error => console.error(error));
  • url (string): The URL of the webpage to scrape.
  • fields (object): The data fields to extract in JSON format.

Example:

client.scrape({
  url: "https://www.amazon.com.au/MSI-PRO-MP341CQW-UltraWide-Compatible/dp/B09Y19TRQ2",
  fields: {
    "monitor_name": "< The product name of the monitor. >",
    "brand": "< The brand or manufacturer name. >",
    "display_size_in_inches": "< Numeric only. >",
    "resolution": "< Example format: 1920x1080. >",
    "panel_type": "< Type of panel. >",
    "refresh_rate_hz": "< Numeric only. >",
    "aspect_ratio": "< Example format: 16:9. >",
    "ports": "< A comma-delimited list of available ports (e.g., HDMI, DisplayPort, etc.). >",
    "features": "< Key selling points or capabilities, comma-delimited (e.g., LED, Full HD, etc.). >",
    "price": "< Numeric price (integer or float). >",
    "price_currency": "< Price currency (3 character alphabetic ISO 4217). >",
    "review_count": "< Total number of customer reviews, numeric only. >",
    "average_rating": "< Float or numeric star rating (e.g., 4.3). >",
    "review_summary": "< A 50 words or less summary of all the written customer feedback. >"
  }
})
.then(result => console.log(result))
.catch(error => console.error(error));

Links Endpoint

Find all links on a page that match a specific description.

client.links({ url, description })
  .then(result => console.log(result))
  .catch(error => console.error(error));
  • url (string): The URL of the webpage to scrape.
  • description (string): Description of the links to extract.

Example:

client.links({
  url: "https://www.ikea.com/au/en/cat/quilt-cover-sets-10680/?page=3",
  description: "individual product urls"
})
.then(result => console.log(result))
.catch(error => console.error(error));

Next Page Endpoint

Extract "Next Page" links from a paginated web page.

client.next({ url })
  .then(result => console.log(result))
  .catch(error => console.error(error));
  • url (string): The URL of the webpage to scrape.

Example:

client.next({
  url: "https://www.ikea.com/au/en/cat/quilt-cover-sets-10680/"
})
.then(result => console.log(result))
.catch(error => console.error(error));

Search Endpoint

Scrape and extract relevant Google search result URLs.

client.search({ query, googleDomain, page })
  .then(result => console.log(result))
  .catch(error => console.error(error));
  • query (string): The search query.
  • googleDomain (string, optional): The Google domain to search on. Defaults to "www.google.com".
  • page (number, optional): The page number to scrape. Defaults to 1.

Example:

client.search({
  query: "AVID POWER 20V MAX Lithium Ion Cordless Drill Set",
  googleDomain: "www.google.com",
  page: 1
})
.then(result => console.log(result))
.catch(error => console.error(error));

Error Handling

The package will throw errors if the API returns an error. You can handle these errors with a try-catch block or the Promise catch method:

client.scrape({
  url: "https://example.com",
  fields: { "title": "< The title of the page. >" }
})
.then(result => {
  console.log(result);
})
.catch(error => {
  console.error("An error occurred:", error.message);
});

Using async/await:

async function getData() {
  try {
    const result = await client.scrape({
      url: "https://example.com",
      fields: { "title": "< The title of the page. >" }
    });
    console.log(result);
  } catch (error) {
    console.error("An error occurred:", error.message);
  }
}

getData();

Need Help?

Join the Discord Community for real-time help and feedback.

License

MIT