Setup
Put them in your environment or
.env; Data APIs covers the other ways.
Notes
- Every command is a GET to /api/json with cmd naming the command; /api/xml answers XML instead. Majestic itself advises POST over GET for production use.
- Costs are in three allowances: Analysis units, Retrieval units (one per row returned) and Index Item units (GetIndexItemInfo only). Each endpoint note says what it spends.
- Set datasource to fresh or historic. The developer sandbox host (developer.majestic.com) returns a reduced dataset at no charge, but this entry targets the live host.
- Responses carry Code and ErrorMessage fields; check them as well as the HTTP status.
Endpoints
Get subscription info
- Uses no units. Check this before large pulls.
Index item info
- Spends one Index Item unit per item queried.
- URLs with very few external backlinks may return estimates, flagged by Status MayExist.
Get backlink data
- Costs 5000 Analysis units per call (more when sorting or filtering), plus one Retrieval unit per row returned.
- Does not return links flagged as alt text.
Get referring domains
- Costs 1000 Analysis units per call plus one Retrieval unit per row.
- Sorting needs no extra units.
Get anchor text
- Costs 1000 Analysis units per call plus one Retrieval unit per row.
Get top pages
- Costs 5000 Analysis units per call plus one Retrieval unit per row.
- The only guaranteed way to check whether a URL is in the index.