Python SDK
Official Python SDK for the RankParse API. Sync and async clients, single dependency (httpx).
Installation
pip install rankparseuv add rankparsepoetry add rankparseRequires Python 3.9+. Single runtime dependency: httpx. See the Python landing page for framework-specific examples.
Quick start
from rankparse import RankParseClient
client = RankParseClient(api_key="rp_...")
result = client.domain_authority("github.com")
print(result["data"]["score"]) # 94
print(result["credits_remaining"]) # 9995Async client
import asyncio
from rankparse import AsyncRankParseClient
async def main():
async with AsyncRankParseClient(api_key="rp_...") as client:
result = await client.domain_authority("github.com")
print(result["data"]["score"])
asyncio.run(main())Configuration
from rankparse import RankParseClient
client = RankParseClient(
api_key="rp_...",
base_url="https://api.rankparse.com/v1", # optional override
timeout=30.0, # seconds, default 30
)Context managers
# Sync
with RankParseClient(api_key="rp_...") as client:
result = client.backlinks("stripe.com")
# Async
async with AsyncRankParseClient(api_key="rp_...") as client:
result = await client.backlinks("stripe.com")Error handling
from rankparse.errors import AuthError, InsufficientCreditsError, RateLimitError
try:
result = client.backlinks("stripe.com")
except AuthError:
print("Invalid API key")
except InsufficientCreditsError:
print("Top up at rankparse.com/dashboard")
except RateLimitError:
print("Back off and retry")All methods
Link graph
| Method | Endpoint | Credits |
|---|---|---|
backlinks(domain, *, limit, offset, sort, from_domain, link_type) | GET /backlinks | 2 |
referring_domains(domain, *, limit, offset) | GET /referring-domains | 2 |
outbound_links(domain, *, limit) | GET /outbound-links | 2 |
anchor_text(domain, *, limit) | GET /anchor-text | 2 |
link_intersect(domain_a, domain_b, *, limit) | GET /link-intersect | 5 |
link_velocity(domain) | GET /link-velocity | 0 (v2) |
new_links(domain) | GET /new-links | 0 (v2) |
lost_links(domain) | GET /lost-links | 0 (v2) |
Domain intelligence
| Method | Endpoint | Credits |
|---|---|---|
domain_authority(domain) | GET /domain-authority | 1 |
domain_rank(domain) | GET /domain-rank | 2 |
domain_overlap(domains, *, limit) | GET /domain-overlap | 5 |
similar_domains(domain, *, limit) | GET /similar-domains | 5 |
competitor_gap(domain, vs, *, limit) | GET /competitor-gap | 5 |
link_audit(domain) | GET /link-audit | 8 |
site_explorer(domain, *, limit) | GET /site-explorer | 10 |
Page & site
| Method | Endpoint | Credits |
|---|---|---|
page_seo(url) | GET /page-seo | 3 |
page_performance(url, *, strategy) | GET /page-performance | 3 |
tech_stack(url) | GET /tech-stack | 2 |
site_health(domain) | GET /site-health | 2 |
sitemap(domain) | GET /sitemap | 2 |
crawl_history(domain, *, limit, offset) | GET /crawl-history | 2 |
top_pages(domain, *, limit) | GET /top-pages | 2 |
schema_markup(url) | GET /schema-markup | 2 |
internal_links(url, *, limit, offset) | 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 |
create_key(name) | Create a new API key |
revoke_key(key_id) | Revoke an API key |
usage(*, limit, offset) | 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. httpx is already installed with the SDK:
import os
import httpx
BASE = "https://api.rankparse.com/v1"
headers = {"X-API-Key": os.environ["RANKPARSE_API_KEY"]}
# GET with query parameters
resp = httpx.get(
f"{BASE}/page-performance",
params={"url": "https://stripe.com", "strategy": "desktop"},
headers=headers,
timeout=60,
)
if resp.is_error:
err = resp.json() # {"error": ..., "code": ..., "message": ...}
raise RuntimeError(f"{resp.status_code} {err['code']}")
body = resp.json()
print(body["data"]["performance_score"], body["credits_remaining"])
# POST with a JSON body
httpx.post(
f"{BASE}/indexnow",
json={"urls": ["https://example.com/new-page"]},
headers=headers,
timeout=60,
)For async code, use httpx.AsyncClient the same way. Errors use the shape documented in Errors; branch on code. The SDK's own exception classes only cover the errors it maps.
Pagination
List endpoints accept limit (default 100, max 1000, larger values are clamped):
links = 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) takes a list of up to 50 domain strings 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.
result = client.batch(["stripe.com", "github.com", "vercel.com"])
for item in result["data"]:
if item["success"]:
print(item["domain"], item["total"], "backlinks returned")
else:
print(item["domain"], "failed:", item["error"])
print(result["credits_used"], result["credits_remaining"])The async client has the same method: await client.batch(domains).
Return value: the standard response envelope. result["data"] holds one entry per valid input domain, in input order. Each entry has domain, success, total and data (up to 100 backlink rows), plus an error string when success is False. credits_used and credits_remaining sit beside data.
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 raise, so check success on each entry. Request-level problems raise: 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.
Pandas enrichment
import pandas as pd
from rankparse import RankParseClient
client = RankParseClient(api_key="rp_...")
df = pd.read_csv("domains.csv")
df["score"] = df["domain"].apply(
lambda d: client.domain_authority(d)["data"]["score"]
)
df.sort_values("score", ascending=False).to_csv("enriched.csv")Source & issues
GitHub: abhibavishi/rankparse-python