Node.js SDK
The official TypeScript client for the RankParse API, version 0.1.1. Zero dependencies, ESM and CommonJS.
rankparse on npm (version 0.1.1) wraps the link graph, live page and account endpoints. It has no runtime dependencies and uses the native fetch of Node.js 18 or later. Everything it does not wrap is one fetch call away, with the same key (see Endpoints the SDK does not cover).
Installation
npm install rankparseSee the Node.js landing page for framework 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);
console.log(result.credits_used, result.credits_remaining);CommonJS works too:
const { RankParse } = require('rankparse');
const client = new RankParse({ apiKey: process.env.RANKPARSE_API_KEY });RankParse is also the default export.
Configuration
const client = new RankParse({
apiKey: 'rp_your_key', // required, sent as X-API-Key
baseUrl: 'https://api.rankparse.com/v1', // optional
timeout: 30_000, // optional, milliseconds, default 30 seconds
});The client sends X-API-Key and Accept: application/json on every request, and Content-Type: application/json when there is a body. It does not retry on its own; see Rate limiting for a backoff loop.
Responses and types
Each method resolves to the parsed JSON body the API returns, so the envelope (data, credits_used, credits_remaining, plus domain, total and limit where they apply) is exactly as documented on each endpoint page. Two methods reshape it:
linkAudit(domain)moves the report fields underdata(the API returns them at the top level) and keepsdomain,credits_used,credits_remainingandcrawl_releasebeside it.keys()returns thekeysarray instead of{ keys: [...] }.
The TypeScript types shipped in 0.1.1 are older than the API and many do not match the live field names. For example DomainAuthorityData declares authority_score, while the API returns score, and credits() is typed as { balance } while GET /v1/credits returns { credits, plan_credits, purchased_credits, plan_credits_expire_at } with no envelope. Read field names from the endpoint pages in the API reference, not from the types.
Methods
Every method returns a Promise. Costs are in credits; see Credits for refunds.
Link graph
| Method | Endpoint | Credits |
|---|---|---|
backlinks(domain, opts?) | GET /v1/backlinks | 2 |
referringDomains(domain, opts?) | GET /v1/referring-domains | 2 |
outboundLinks(domain, { limit }?) | GET /v1/outbound-links | 2 |
anchorText(domain, { limit }?) | GET /v1/anchor-text | 2 |
topPages(domain, { limit }?) | GET /v1/top-pages | 2 |
domainAuthority(domain) | GET /v1/domain-authority | 1 |
domainRank(domain) | GET /v1/domain-rank | 2 |
siteExplorer(domain, { limit }?) | GET /v1/site-explorer | 10 |
batch(domains) | POST /v1/batch | 2 per successful domain |
backlinks options: limit, sort ('importance' or 'recent'), from_domain, link_type. referringDomains options: limit. Both types also accept offset, which the API ignores. The SDK has no option for score=true; call the endpoint over HTTP for scored rows.
Competitive analysis
| Method | Endpoint | Credits |
|---|---|---|
domainOverlap(domains, { limit }?) | GET /v1/domain-overlap | 5 |
linkIntersect(domainA, domainB, { limit }?) | GET /v1/link-intersect | 5 |
similarDomains(domain, { limit }?) | GET /v1/similar-domains | 5 |
competitorGap(domain, vs, { limit }?) | GET /v1/competitor-gap | 5 |
linkAudit(domain) | GET /v1/link-audit | 8 |
domainOverlap takes an array of 2 to 5 domains and joins it with commas.
Live page analysis
| Method | Endpoint | Credits |
|---|---|---|
pageSeo(url) | GET /v1/page-seo | 3 |
pagePerformance(url, { strategy }?) | GET /v1/page-performance | 3 |
schemaMarkup(url) | GET /v1/schema-markup | 2 |
siteHealth(domain) | GET /v1/site-health | 2 |
sitemap(domain) | GET /v1/sitemap | 2 |
techStack(domain) | GET /v1/tech-stack | 2 |
crawlHistory(domain) | GET /v1/crawl-history | 2 |
strategy is 'mobile' (the API default) or 'desktop'. crawlHistory also accepts limit and offset, which the API ignores. sitemap takes no limit option, so it always returns the default 100 URLs.
Not yet available
| Method | Endpoint | Credits |
|---|---|---|
linkVelocity(domain) | GET /v1/link-velocity | 0 |
newLinks(domain) | GET /v1/new-links | 0 |
lostLinks(domain) | GET /v1/lost-links | 0 |
They return status: "not_yet_available". internalLinks(url, opts?) also exists, but it sends url where the API expects domain, so in 0.1.1 it fails with 400 invalid_domain.
Account
| Method | Endpoint | Returns |
|---|---|---|
credits() | GET /v1/credits | { credits, plan_credits, purchased_credits, plan_credits_expire_at } |
me() | GET /v1/me | { id, email, credits, created_at } (credits is null for a role that cannot view credits) |
keys() | GET /v1/keys | An array of { id, name, last_four, created_at } |
createKey(name?) | POST /v1/keys | { id, key, name, created_at }. The raw key is shown once. |
revokeKey(keyId) | DELETE /v1/keys/:id | Nothing |
usage({ limit, offset }?) | GET /v1/usage | { usage, total }. limit defaults to 50, max 200. |
These are free. checkout(packId) is also in 0.1.1, but it sends pack_id where POST /v1/checkout expects credits, so it fails with 400 invalid_credits. Buy credits in the dashboard instead.
Batch lookup
batch(domains: string[]) returns Promise<ApiResponse<BatchResultItem[]>>. It runs a backlinks lookup for up to 50 domains in one request:
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);result.dataholds one entry per valid input domain, in order, each withdomain,successand eithertotalanddata(backlink rows) orerror.- 2 credits per domain that succeeds; failed domains are free. Invalid domains are dropped before the lookup.
- More than 50 valid domains throws
APIErrorwith codetoo_many_domains. A batch counts as one request against the rate limit of 60 requests per minute per key (Rate limiting).
Error handling
Any non-2xx response throws. The class depends on the status:
| Class | Status | Extends |
|---|---|---|
AuthError | 401 | RankParseError |
InsufficientCreditsError | 402 (also spend_cap_reached and plan_limit_reached) | RankParseError |
NotFoundError | 404 | RankParseError |
RateLimitError | 429 (also daily caps such as user_quota_exceeded) | RankParseError |
APIError | Anything else, and a timeout (code: 'timeout', status: 0) | RankParseError |
Each error has message, status and code. code is the API's error code (falling back to its error field, then unknown_error), so branch on it for the cases that share a status:
import { RankParse, RankParseError, RateLimitError, InsufficientCreditsError } from 'rankparse';
try {
await client.backlinks('stripe.com');
} catch (err) {
if (err instanceof RateLimitError && err.code === 'rate_limited') {
// back off and retry
} else if (err instanceof InsufficientCreditsError) {
// err.code is insufficient_credits, spend_cap_reached or plan_limit_reached
} else if (err instanceof RankParseError) {
console.error(err.status, err.code, err.message);
} else {
throw err;
}
}The full list of codes is in Errors.
Endpoints the SDK does not cover
0.1.1 has no methods for these. Call them over HTTP with the same key:
platform-domainsandplatform-trendsscore=trueonbacklinksandreferring-domains, andlimitonsitemap- Websites, rank tracking, Search Console, Google Ads
- Issues, indexing, the AI visibility scan and IndexNow
- Proposals, agent tasks, client report and outreach
GET /v1/pricing,POST /v1/checkoutand the internal links stub (see above)
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({ platform: 'shopify', limit: '25' });
const res = await fetch(`${BASE}/platform-domains?${params}`, { headers });
if (!res.ok) {
const err = await res.json(); // { error, code, message? }
throw new Error(`${res.status} ${err.code}`);
}
const { data, credits_used, 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'] }),
});Source and issues
GitHub: abhibavishi/rankparse-node