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

@z-scraper/crypto-api

v1.0.1

Published

A TypeScript/JavaScript SDK for the Crypto API that lets you fetch aggregated crypto news from multiple sources and AI-powered sentiment analysis through RapidAPI with minimal setup.

Readme

@z-scraper/crypto-api

TypeScript/JavaScript SDK for the Crypto API – aggregate crypto news from multiple sources with AI-powered sentiment analysis via RapidAPI.

npm version npm downloads CI Coverage Status License

👉 Live API on RapidAPI: Crypto API

The @z-scraper/crypto-api package provides a simple, type-safe client for the Crypto API, which aggregates cryptocurrency news from multiple major sources and enriches it with AI sentiment (positive / negative / neutral).

This SDK is designed for developers building:

  • 🧠 Trading bots that use news + sentiment as signals
  • 📊 Dashboards & alerting systems
  • 📚 Research tools & data pipelines

Features

  • 📡 Single client for all Crypto API endpoints
  • 📰 Aggregated news from multiple sources (e.g. CoinDesk, Cointelegraph, etc.)
  • 🧠 AI-powered sentiment per article
  • 🎯 Easy filter parameters (source, sentiment, date range, limit, pagination…)
  • ✅ First-class TypeScript types for inputs & responses
  • 🧪 100% unit test coverage with Vitest and strict coverage thresholds

Installation

npm install @z-scraper/crypto-api
# or
yarn add @z-scraper/crypto-api
# or
pnpm add @z-scraper/crypto-api

Node.js: >=18 is recommended.


Getting started

1. Get your RapidAPI key

  1. Go to the Crypto API listing on RapidAPI
  2. Subscribe to a plan
  3. Copy your x-rapidapi-key

2. Create a client

import { CryptoApiClient } from '@z-scraper/crypto-api';

const client = new CryptoApiClient({
  apiKey: process.env.RAPIDAPI_KEY as string,
  // Optional: override baseURL if needed
  // baseURL: "https://z-crypto-news.p.rapidapi.com",
});

Quickstart

Fetch latest news

import { CryptoApiClient } from '@z-scraper/crypto-api';

async function main() {
  const client = new CryptoApiClient({
    apiKey: process.env.RAPIDAPI_KEY as string,
  });

  const news = await client.getNews();

  console.log(`Fetched ${news.articles.length} articles`);
  console.log(news.articles[0]);
}

main().catch(console.error);

Filter by source & sentiment

const res = await client.getNews({
  source: 'coindesk',
  sentiment: 'positive',
  limit: 20,
});

for (const article of res.articles) {
  console.log(`[${article.sentiment}] ${article.title}`);
}

Fetch a single article by ID

const article = await client.getArticleById('ARTICLE_ID_HERE');

console.log(article.title);
console.log(article.content);

API

⚠️ The exact shape of responses and available filters may evolve as the Crypto API grows.
Always refer to the official API docs on RapidAPI for the latest details.

CryptoApiClient

new CryptoApiClient(options: CryptoApiClientOptions)

CryptoApiClientOptions

interface CryptoApiClientOptions {
  /**
   * Your RapidAPI key for the Crypto API.
   */
  apiKey: string;

  /**
   * Optional base URL override.
   * Defaults to the public Crypto API base URL.
   */
  baseURL?: string;

  /**
   * Optional request timeout in milliseconds.
   * Default: 10_000 (10 seconds)
   */
  timeoutMs?: number;
}

client.getNews(params?)

Fetches a list of news articles, optionally filtered by source, sentiment, or date range.

interface GetNewsParams {
  source?: string; // e.g. "coindesk", "cointelegraph"
  sentiment?: 'positive' | 'negative' | 'neutral';
  from?: string; // ISO 8601 date, e.g. "2025-01-01"
  to?: string; // ISO 8601 date
  limit?: number; // number of articles to return
  page?: number; // pagination
}

interface NewsArticle {
  id: string;
  title: string;
  url: string;
  source: string;
  publishedAt: string; // ISO 8601
  sentiment?: 'positive' | 'negative' | 'neutral';
  summary?: string;
  content?: string;
  [key: string]: unknown;
}

interface GetNewsResponse {
  articles: NewsArticle[];
  total?: number;
  page?: number;
  hasMore?: boolean;
}

Example:

const result = await client.getNews({
  source: 'coindesk',
  sentiment: 'negative',
  limit: 10,
});

console.log(result.articles.map((a) => a.title));

client.getArticleById(id)

Fetch full details for a single article.

const article = await client.getArticleById('some-article-id');

console.log(article.title);
console.log(article.sentiment);
console.log(article.content);

Configuration

Environment variables

Typical .env:

RAPIDAPI_KEY=your_rapidapi_key_here

Usage:

const client = new CryptoApiClient({
  apiKey: process.env.RAPIDAPI_KEY as string,
});

Custom base URL

If you run your own gateway / proxy:

const client = new CryptoApiClient({
  apiKey: process.env.RAPIDAPI_KEY as string,
  baseURL: 'https://my-proxy.example.com/crypto-api',
});

Error handling

All methods throw on HTTP or API-level errors.

try {
  const result = await client.getNews({ source: 'coindesk' });
  console.log(result.articles.length);
} catch (err: any) {
  // Example:
  // - invalid API key
  // - rate limit exceeded
  // - network error, etc.
  console.error('Crypto API request failed:', err.message || err);
}

If you need more control, you can inspect err.response when using Axios under the hood (depending on implementation).


TypeScript support

This SDK is written in TypeScript and ships its own type definitions:

import type { GetNewsParams, NewsArticle } from '@z-scraper/crypto-api';

You get autocompletion and type checking out of the box in modern editors.


Testing

This repository is configured to use:

Run all tests

npm test
# or
npm run test

Recommended structure

src/
  index.ts
  client.ts
test/
  unit/
    client.test.ts
  integration/
    client.integration.test.ts
  • Unit tests mock HTTP requests and do not hit the real API.
  • Integration tests (optional) can call the real API using RAPIDAPI_KEY from your environment.

Versioning & stability

The SDK currently follows 0.x versioning while the API and client surface are being refined.

  • 0.0.x: prototype / internal testing
  • 0.1.x: early public use, breaking changes possible
  • 1.x: stable, semver guarantees for the public API surface

Breaking changes in 0.x may happen without a major version bump. Check the changelog and release notes when upgrading.


Roadmap

Planned improvements:

  • ✅ Basic news listing & article detail helpers
  • ✅ 100% unit test coverage with strict thresholds
  • ⏳ Convenience methods for sentiment-only / summary views
  • ⏳ Built-in pagination helpers
  • ⏳ Additional utilities for trading-bot workflows

Feature requests & PRs are very welcome!


License

This SDK is released under the MIT License.


Support

If you run into issues:

  • Open an Issue
  • Describe:
    • SDK version
    • Node version
    • Example code
    • Full error message

If this SDK is useful to you, a ⭐ on the repo helps a lot!