Anchor Text
What's Covered?
In this guide you’ll learn more about making API calls to the Anchor Text endpoint for the Links API V2.
Use this endpoint to get data about anchor text used by followed external links to a target. Results are ordered by external_root_domains descending.
This documentation specifies information for Moz Links API V2. V1 documentation is available here.
Quick Links
Getting Started
Before making calls to the Anchor Text endpoint, be sure you are set up with an Access ID and Secret Key within your Moz Account.
Just a reminder - the Links API V2 supports Basic Auth in which you are able to use your Access ID as a username and and your Secret Key as a password.
All requests and responses are structured in JSON.
Endpoint Location
When requesting anchor text data from Links V2, be sure to use the following endpoint.
https://lsapi.seomoz.com/v2/anchor_text
Request Syntax
{ "target": "string", "scope": "string", "limit": number, "next_token: "string }
Example JSON Request
{ "target": "moz.com/blog", "scope": "page", "limit": 1 }
Request Parameters
"target" - The target to get anchor text for.
- Type: string
- Required: yes
"scope" - Get anchor text from links to target at this scope. The default value is 'page'.
- Type: string
- Required: no
- Valid Values: page, subdomain, root_domain
"limit" - Only return up to this number of results. The default value is 25.
- Type: number
- Required: no
- Valid Values: 1-50
"next_token" - If set, return the next set of results from a previous request whose 'next_token' element equals this value.
- Type: string
- Required: no
Response Syntax
{ "results": [{ "anchor_text": "string", "external_root_domains": number, "external_pages": number }], "next_token": "string" }
Example JSON Response
{ "results": [ { "anchor_text": "moz blog", "external_root_domains": 97, "external_pages": 1089 } ], "next_token": "CePTfmAHP9iRBWDiz1qTw=" }
Response Elements
"results" -An array of json maps representing the anchor text that links to 'target'.
- Type: Array of Map objects
"anchor_text" - The anchor text string, after normalization. See the 'anchor_text' request parameter in the 'links' endpoint for a description of the steps used for normalization.
- Type: string
"external_root_domains" - The number of unique root domains linking to 'target' with this anchor text.
- Type: number
"external_pages" - The number of unique pages from a different root domain linking to 'target' with this anchor text.
- Type: number
"next_token" - If non-empty, the number of results was limited by the 'limit' parameter, and the next set of results can be obtained by repeating the request with the 'next_token' request parameter set to this value.
- Type: string
Limits
None (it's possible to iterate through every unique piece of anchor text used to link to a target)
Errors
See the Common Errors section for errors that are common to all endpoints.
Gone Message: The next token has expired HTTP Status code: 410
Example HTTP Request
POST /v2/anchor_text Host: lsapi.seomoz.com Content-Length: [length of request payload in bytes] User-Agent: [user agent string] Authorization: Basic [credentials] { "target": "moz.com/blog", "scope": "page", "limit": 1 }
Example cURL Request
curl -d '{"target": "moz.com/blog", "scope": "page", "limit": 1}' -X POST https://lsapi.seomoz.com/v2/anchor_text -u 'access_id:secret_key'
Example Python Request
import requests auth = (access_id, secret_key) url = "https://lsapi.seomoz.com/v2/anchor_text" data = """{ "target": "moz.com/blog","scope": "page", "limit": 5 }""" request = requests.post(url, data=data, auth=auth)
Related Articles
Was this article helpful?
Yes! Amazing! Yes! It was what I needed. Meh. It wasn’t really what I was looking for. No, it wasn’t helpful at all.
Thanks for the feedback.