Node.js SDK
Official TypeScript SDK for the RankParse API. Zero dependencies, dual ESM/CJS, typed responses.
Installation
npm install rankparsepnpm add rankparseyarn add rankparseRequires Node.js 18+. No runtime dependencies; it uses native fetch. See the Node.js landing page for framework-specific examples.
Quick start
import { RankParse } from 'rankparse';
const client = new RankParse({ apiKey: process.env.RANKPARSE_API_KEY! });
const result = await client.domainAuthority('github.com');
console.log(result.data.score); // 94
console.log(result.credits_remaining); // 9995CommonJS
const { RankParse } = require('rankparse');
const client = new RankParse({ apiKey: process.env.RANKPARSE_API_KEY });Configuration
const client = new RankParse({
apiKey: 'rp_...',
baseUrl: 'https://api.rankparse.com/v1', // optional override
timeout: 30_000, // ms, default 30s
});Error handling
import { RankParse, AuthError, InsufficientCreditsError, RateLimitError } from 'rankparse';
try {
const result = await client.backlinks('stripe.com');
} catch (err) {
if (err instanceof AuthError) {
// Invalid API key
} else if (err instanceof InsufficientCreditsError) {
// Top up at rankparse.com/dashboard
} else if (err instanceof RateLimitError) {
// Back off and retry
}
}All methods
Link graph
| Method | Endpoint | Credits |
|---|---|---|
backlinks(domain, opts?) | GET /backlinks | 2 |
referringDomains(domain, opts?) | GET /referring-domains | 2 |
outboundLinks(domain, opts?) | GET /outbound-links | 2 |
anchorText(domain, opts?) | GET /anchor-text | 2 |
linkIntersect(domainA, domainB, opts?) | GET /link-intersect | 5 |
linkVelocity(domain) | GET /link-velocity | 0 (v2) |
newLinks(domain) | GET /new-links | 0 (v2) |
lostLinks(domain) | GET /lost-links | 0 (v2) |
Domain intelligence
| Method | Endpoint | Credits |
|---|---|---|
domainAuthority(domain) | GET /domain-authority | 1 |
domainRank(domain) | GET /domain-rank | 2 |
domainOverlap(domains[], opts?) | GET /domain-overlap | 5 |
similarDomains(domain, opts?) | GET /similar-domains | 5 |
competitorGap(domain, vs, opts?) | GET /competitor-gap | 5 |
linkAudit(domain) | GET /link-audit | 8 |
siteExplorer(domain, opts?) | GET /site-explorer | 10 |
Page & site
| Method | Endpoint | Credits |
|---|---|---|
pageSeo(url) | GET /page-seo | 3 |
pagePerformance(url, opts?) | GET /page-performance | 3 |
techStack(url) | GET /tech-stack | 2 |
siteHealth(domain) | GET /site-health | 2 |
sitemap(domain) | GET /sitemap | 2 |
crawlHistory(domain, opts?) | GET /crawl-history | 2 |
topPages(domain, opts?) | GET /top-pages | 2 |
schemaMarkup(url) | GET /schema-markup | 2 |
internalLinks(url, opts?) | GET /internal-links | 0 (v2) |
Batch & dashboard
| Method | Description |
|---|---|
batch(domains) | Backlinks for up to 50 domains in one call, 2 credits per successful domain |
me() | Current user profile + credit balance |
credits() | Credit balance |
keys() | List API keys |
createKey(name?) | Create a new API key |
revokeKey(keyId) | Revoke an API key |
usage(opts?) | Paginated usage logs |
Method parameters mirror the matching endpoint pages, and every response keeps the API's envelope (data, credits_used, credits_remaining).
Calling endpoints not yet wrapped
The method tables above list what the SDK wraps. Any endpoint without a method, for example page-performance if your installed version lacks it, IndexNow, Google Search Console or rank tracking, can be called over plain HTTP with the same API key. Node 18+ has fetch built in:
const BASE = "https://api.rankparse.com/v1";
const headers = { "X-API-Key": process.env.RANKPARSE_API_KEY! };
// GET with query parameters
const params = new URLSearchParams({ url: "https://stripe.com", strategy: "desktop" });
const res = await fetch(`${BASE}/page-performance?${params}`, { headers });
if (!res.ok) {
const err = await res.json(); // { error, code, message? }
throw new Error(`${res.status} ${err.code}`);
}
const { data, credits_remaining } = await res.json();
// POST with a JSON body
const submit = await fetch(`${BASE}/indexnow`, {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({ urls: ["https://example.com/new-page"] }),
});Errors use the shape documented in Errors; branch on code. The SDK's own error classes only cover the errors it maps.
Pagination
List endpoints accept limit (default 100, max 1000, larger values are clamped):
const links = await client.backlinks('stripe.com', { limit: 500 });The link-graph endpoints return the top limit rows rather than pages, so there is no offset to walk. Only endpoints that document an offset parameter, such as rank tracking and usage, paginate. See Response format.
Batch lookup
batch(domains: string[]) takes up to 50 domains and runs a backlinks lookup for each one. It is a wrapper for POST /v1/batch and needs SDK version 0.1.1 or later. It does not take mixed endpoints or per-domain options; for those, call the individual methods.
const result = await client.batch(['stripe.com', 'github.com', 'vercel.com']);
for (const item of result.data) {
console.log(item.domain, item.success ? item.total : item.error);
}
console.log(result.credits_used, result.credits_remaining);Return value: Promise<ApiResponse<BatchResultItem[]>>, the standard envelope. result.data holds one entry per valid input domain, in input order. Each BatchResultItem has domain, success, and optional total, data (up to 100 backlink rows) and error (set when success is false).
Credits and limits:
- 2 credits per domain that succeeds. Failed domains are not charged.
- 50 domains per call, after invalid entries are dropped. Chunk longer lists.
- Rate limit: 60 requests per minute per key, and a batch counts as one request.
Errors: a failing domain does not throw, so check success on each entry. Request-level problems throw: InsufficientCreditsError (402), RateLimitError (429), AuthError (401), or APIError for the rest, such as invalid_domains or too_many_domains (400). See the batch endpoint page for the full response shape.
Source & issues
GitHub: abhibavishi/rankparse-node