Skip to Content

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 rankparse

See 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 under data (the API returns them at the top level) and keeps domain, credits_used, credits_remaining and crawl_release beside it.
  • keys() returns the keys array 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.

MethodEndpointCredits
backlinks(domain, opts?)GET /v1/backlinks2
referringDomains(domain, opts?)GET /v1/referring-domains2
outboundLinks(domain, { limit }?)GET /v1/outbound-links2
anchorText(domain, { limit }?)GET /v1/anchor-text2
topPages(domain, { limit }?)GET /v1/top-pages2
domainAuthority(domain)GET /v1/domain-authority1
domainRank(domain)GET /v1/domain-rank2
siteExplorer(domain, { limit }?)GET /v1/site-explorer10
batch(domains)POST /v1/batch2 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

MethodEndpointCredits
domainOverlap(domains, { limit }?)GET /v1/domain-overlap5
linkIntersect(domainA, domainB, { limit }?)GET /v1/link-intersect5
similarDomains(domain, { limit }?)GET /v1/similar-domains5
competitorGap(domain, vs, { limit }?)GET /v1/competitor-gap5
linkAudit(domain)GET /v1/link-audit8

domainOverlap takes an array of 2 to 5 domains and joins it with commas.

Live page analysis

MethodEndpointCredits
pageSeo(url)GET /v1/page-seo3
pagePerformance(url, { strategy }?)GET /v1/page-performance3
schemaMarkup(url)GET /v1/schema-markup2
siteHealth(domain)GET /v1/site-health2
sitemap(domain)GET /v1/sitemap2
techStack(domain)GET /v1/tech-stack2
crawlHistory(domain)GET /v1/crawl-history2

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

MethodEndpointCredits
linkVelocity(domain)GET /v1/link-velocity0
newLinks(domain)GET /v1/new-links0
lostLinks(domain)GET /v1/lost-links0

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

MethodEndpointReturns
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/keysAn 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/:idNothing
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.data holds one entry per valid input domain, in order, each with domain, success and either total and data (backlink rows) or error.
  • 2 credits per domain that succeeds; failed domains are free. Invalid domains are dropped before the lookup.
  • More than 50 valid domains throws APIError with code too_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:

ClassStatusExtends
AuthError401RankParseError
InsufficientCreditsError402 (also spend_cap_reached and plan_limit_reached)RankParseError
NotFoundError404RankParseError
RateLimitError429 (also daily caps such as user_quota_exceeded)RankParseError
APIErrorAnything 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:

Plain HTTP call
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

On this page