GetAnchorText

Command status: Active
Supported by OpenApps API: Yes
Supported by Internal/Reseller API: Yes
Possibly queued processing: No

This function returns Anchor text for a given domain, subdomain or URL, as well as allowing you to filter the results by a keyword

Resource Description

AnalysisResUnits

1000

RetrievalResUnits

Actual number of rows of data returned

This function accepts the following parameters:

Parameter Description

cmd

Required: must be set to: GetAnchorText

datasource

Optional - defaults to historic
Either: "fresh" - to query against fresh index, or "historic" - to query against historic index.

item

URL/Subdomain/Domain to query

TextMode

0 (default) - returns anchor text (forced to lower case) as it was found with all punctunation marks etc
1 - cleans up anchor text by removing punctunation marks and other delimiters

Mode

Determines the kind of data that will be returned back:
0 (default - returns aggregated anchor text stats.
1 - referring domains will be returned for exact match of supplied anchor text.
2 - returns backlinks for given anchor text OR ref domains, ONLY valid if variable CanReturnURLs was set to 1 when querying anchor text or ref domains.

FilterAnchorText

Applied to filter anchor text FilterAnchorTextMode was set to appropriate mode.

FilterAnchorTextMode

0 (default) - no filter on anchor text
1 - exact matching specified anchor text in FilterAnchorText parameter
2 - matching all anchor texts containing specified FilterAnchorText

FilterRefDomain

Used only in cases when backlinks need to be returned for a particular ref domain.

Count

Number of results (anchor text, ref domains or backlinks) to be returned back.

Default: 10, Maximum: 1000

UsePrefixScan

Optional: Setting to 1 will activate prefix mode.

This operates like the "Path ( URL* )" functionality in Majestic Site Explorer on the majestic.com website.

This commands will check if real time querying of given item is possible, if that's not the case then RealTimePrefixQueryNotPossible error code will be returned.

See also Get Prefix Query Estimate

Example 1

Below you can see example of query for aggregated anchor text matching particular keyword: majestic:
http://api.majestic.com/api/xml?app_api_key=API_KEY&cmd=GetAnchorText&item=http://www.majestic.com&FilterAnchorText=majestic

This produces the following XML:



http://api.majestic.com/api/json?app_api_key=API_KEY&cmd=GetAnchorText&item=majestic.com&FilterAnchorText=majestic

This produces the following JSON:

Query results will be returned in datatable named AnchorText with the following headers:

  1. AnchorText - anchor text
  2. RefDomains - number of referring domains with given anchor text
  3. TotalLinks - total number of backlinks (external) with given anchor text
  4. DeletedLinks - number of links that were marked as deleted
  5. NoFollowLinks - number of links that were nofollow
  6. EstimatedLinkCitationFlow - estimated Citation Flow of referring links that pass it (nofollow links ignored)
  7. EstimatedLinkTrustFlow - - estimated Trust Flow of referring links that pass it (nofollow links ignored)

Example 2

Below you can see example of a query that will return referring domains links from which used majestic as exact anchor text:
http://api.majestic.com/api/xml?app_api_key=API_KEY&cmd=GetAnchorText&item=http://www.majestic.com&FilterAnchorText=majestic&Mode=1

This produces the following XML:

http://api.majestic.com/api/json?app_api_key=API_KEY&cmd=GetAnchorText&item=http://www.majestic.com&FilterAnchorText=majestic&Mode=1

This produces the following JSON:

Query results will be returned in datatable named RefDomains with the following headers:

  1. RefDomain - referring domain
  2. IP - IP address of the domain
  3. CountryCode - geo-located country where domain is hosted based on IP address
  4. CitationFlow - Citation Flow of the referring domain
  5. TrustFlow - Trust Flow of the referring domain
  6. TotalLinks - total number of backlinks (external) with given anchor text
  7. DeletedLinks - number of links that were marked as deleted
  8. NoFollowLinks - number of links that were nofollow
  9. EstimatedLinkCitationFlow - estimated Citation Flow of referring links that pass it (nofollow links ignored)
  10. EstimatedLinkTrustFlow - - estimated Trust Flow of referring links that pass it (nofollow links ignored)

Example 3

Below you can see example of a query that will return actual backlinks using majestic as exact anchor text:
http://api.majestic.com/api/xml?app_api_key=API_KEY&cmd=GetAnchorText&item=http://www.majestic.com&FilterAnchorText=majestic&Mode=2
Please note that backlink queries will only work if previous queries for the same index item returned variable CanReturnURLs="1", otherwise query won't return any results (typically happens for large domains).

This produces the following XML:

http://api.majestic.com/api.json?app_api_key=API_KEY&cmd=GetAnchorText&item=http://www.majestic.com&FilterAnchorText=majestic&Mode=2

This produces the following JSON:

Query results will be returned in datatable named BackLinks with the headers that are the same as in GetBackLinkData command.

Notes:

  1. Variables set on table with returned data called CanReturnURLs indicates if index can return backlinks for given query-1 it can, 0 - not (In such case don't show + sign to drill into backlinks)
  2. Variable TotalResults returns max number of results that can be returned, this should be used for paging logic.
  3. Variables TotalBackLinks="1" and TotalRedDomains="1" returns sum of backlinks and refdomains, most meaningful for aggregated anchor text and red domains to show %-tages each of them have the total
  4. Simple paging logic is supported: From=0 and Count=10 to page

For more information about access to the Majestic API suite, visit our Plans & Pricing page.