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.
npm install @z-scraper/crypto-api> TypeScript/JavaScript SDK for the Crypto API β aggregate crypto news from multiple sources with AI-powered sentiment analysis via RapidAPI.





π 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
---
- π‘ 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
---
``bash`
npm install @z-scraper/crypto-apior
yarn add @z-scraper/crypto-apior
pnpm add @z-scraper/crypto-api
> Node.js: >=18 is recommended.
---
1. Go to the Crypto API listing on RapidAPI
2. Subscribe to a plan
3. Copy your x-rapidapi-key
`ts
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",
});
`
---
`ts
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);
`
`ts
const res = await client.getNews({
source: 'coindesk',
sentiment: 'positive',
limit: 20,
});
for (const article of res.articles) {
console.log([${article.sentiment}] ${article.title});`
}
`ts
const article = await client.getArticleById('ARTICLE_ID_HERE');
console.log(article.title);
console.log(article.content);
`
---
> β οΈ 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.
`ts`
new CryptoApiClient(options: CryptoApiClientOptions)
#### CryptoApiClientOptions
`ts
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;
}
`
---
Fetches a list of news articles, optionally filtered by source, sentiment, or date range.
`ts
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:
`ts
const result = await client.getNews({
source: 'coindesk',
sentiment: 'negative',
limit: 10,
});
console.log(result.articles.map((a) => a.title));
`
---
Fetch full details for a single article.
`ts
const article = await client.getArticleById('some-article-id');
console.log(article.title);
console.log(article.sentiment);
console.log(article.content);
`
---
Typical .env:
`bash`
RAPIDAPI_KEY=your_rapidapi_key_here
Usage:
`ts`
const client = new CryptoApiClient({
apiKey: process.env.RAPIDAPI_KEY as string,
});
If you run your own gateway / proxy:
`ts`
const client = new CryptoApiClient({
apiKey: process.env.RAPIDAPI_KEY as string,
baseURL: 'https://my-proxy.example.com/crypto-api',
});
---
All methods throw on HTTP or API-level errors.
`ts`
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).
---
This SDK is written in TypeScript and ships its own type definitions:
`ts`
import type { GetNewsParams, NewsArticle } from '@z-scraper/crypto-api';
You get autocompletion and type checking out of the box in modern editors.
---
This repository is configured to use:
- Vitest for unit tests
- Nock to mock HTTP calls
`bash`
npm testor
npm run test
`txt`
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.
---
The SDK currently follows 0.x versioning while the API and client surface are being refined.
- 0.0.x: prototype / internal testing0.1.x
- : early public use, breaking changes possible1.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.
---
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!
---
This SDK is released under the MIT License.
---
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!