XFarr API Wrapper

3.0.1 · active · verified Sun Apr 19

xfarr-api is a JavaScript/TypeScript module providing a full implementation of the `api.xfarr.com` REST API, designed for use in Node.js environments. It currently stands at version 3.0.1, indicating active development, though a specific release cadence is not detailed. The library acts as a client for various web scraping and utility features exposed by the xfarr.com service, such as 'stalking' npm package information. Its primary differentiator is providing a structured, promise-based interface to a third-party API, simplifying interaction and abstracting HTTP requests, requiring an API key for all operations.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates initializing the API wrapper with an API key and making two example API calls using the promise-based interface.

import APIWrapper from 'xfarr-api';

const API_KEY = process.env.XFARR_API_KEY ?? ''; // Ensure your API key is set as an environment variable

if (!API_KEY) {
  console.error('Error: XFARR_API_KEY environment variable is not set.');
  process.exit(1);
}

const xfar = new APIWrapper(API_KEY);

// Example of an API call: fetching npm package information
xfar.stalking.npmjs("xfarr-api")
  .then(response => {
    console.log('NPM Stalking Result:', response);
  })
  .catch(error => {
    console.error('Error during NPM stalking:', error.message);
  });

// Another example: (assuming 'random' feature exists and takes no params)
xfar.random.meme()
  .then(response => {
    console.log('Random Meme:', response);
  })
  .catch(error => {
    console.error('Error fetching random meme:', error.message);
  });

view raw JSON →