08 May 2011

By - 24 Comments

SEOmoz Linkscape API is an extremely powerful tool for SEOs, but SEOs often do not come from a development background, and might find the API inaccessible to them. Whilst I believe SEOs should learn to code somewhat, I know not everyone is from that school of thought. If you are unfamiliar with the API, then you can see the SEOmoz API wiki; we’re going to be looking at the URL Metrics API.

Luckily, a recent blog post from Ian Lurie details using Linkscape API with Google Spreadsheets. Ian’s post is great, and probably does exactly what you are looking for. What I post here is a modified version the code from his post, which I used to form the basis of a competitive analysis tool detailed in my recent SEOmoz post: Competitive Analysis in under 60 Seconds using Google Docs.

You can see the code in action in my example spreadsheet (you’ll need to copy if and add your SEOmoz API key), or take a peek here:

  1. var AccessID;
  2. var secret;
  3.  
  4. function readLinkscapeConfig() {
  5.  var active_spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  6.  var config_sheet = active_spreadsheet.getSheetByName("Config");
  7.  params = config_sheet.getRange(1,2,2,2).getValues();
  8.  AccessID = params[0][0];
  9.  secret = params[1][0];
  10. }
  11.  
  12. function generateExpiry() {
  13.  method = "HMAC_SHA_1";
  14.  uDate = new Date().getTime();
  15.  uDate = Math.round(uDate/1000);
  16.  Expires = uDate + 1200;
  17.  
  18.  return Expires;
  19. }
  20.  
  21. function generateSignature(Expires) {
  22.  theString = AccessID + "\n" + Expires;
  23.  signature = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_SHA_1,theString,secret);
  24.  signature64 = Utilities.base64Encode(signature);
  25.  signature64 = encodeURIComponent(signature64);
  26.  
  27.  return signature64;
  28. }
  29.  
  30. function getLinkscapeData(url, dummy) {
  31.  readLinkscapeConfig();
  32.  
  33.  Expires = generateExpiry();
  34.  signature64 = generateSignature(Expires);
  35.  inV="http://lsapi.seomoz.com/linkscape/url-metrics/" + url + "?AccessID=" + AccessID + "&Expires=" + Expires + "&Signature=" + signature64 + "&Cols=85899378688";
  36.  jsonStringResponse = UrlFetchApp.fetch(inV);
  37.  
  38.  var data1 = jsonStringResponse.getContentText();
  39.  data2 = Utilities.jsonParse(data1);
  40.  IDomains = data2["fipl"];
  41.  Dauth = data2["pda"];
  42.  mzRnk = data2["fmrp"];
  43.  
  44.  
  45.  var returnData = new Array(3);
  46.  returnData[0] = mzRnk.toFixed(2);
  47.  returnData[1] = Dauth.toFixed(2);;
  48.  returnData[2] = IDomains;
  49.  
  50.  return returnData;
  51. }

In Google Spreadsheets, you can select “Make a copy” in the File menu to create your own private copy of the spreadsheet to work on. You’ll need to add your SEOmoz API Access ID and secret key (from SEOmoz API page) to the ‘Config’ sheet. You can select Tools -> Script Editor in order to see and edit the code to your own purposes, if you’d like to return a different combination of metrics.

Editing the Code

I return 3 pieces of information about a URL: mozRank, Domain Authority, and linking root domains to the subdomain of the URL.
Results from Linkscape API pulled into Google Docs

However, you can change that my modifying this section of the code:

  1.  var data1 = jsonStringResponse.getContentText();
  2.  data2 = Utilities.jsonParse(data1);
  3.  IDomains = data2["fipl"];
  4.  Dauth = data2["pda"];
  5.  mzRnk = data2["fmrp"];

The codes fipl, pda, and fmrp refer to pieces of information the API is able to give you; you can find a full list of them on the URL Metrics API wiki page. Be sure to check the right hand column to see if they are included in the free API if that is all you have access to. You can edit the above code to include those you want, but that isn’t the end of the story, you also need to edit a couple of other pieces:

  1.  inV="http://lsapi.seomoz.com/linkscape/url-metrics/" + url + "?AccessID=" + AccessID + "&Expires=" + Expires + "&Signature=" + signature64 + "&Cols=85899378688";

The number 85899378688 is a mask which tells the API which columns to passback (you could always just ask for them all, but that puts more load on the API servers, and isn’t polite!). It is based around how computers store numbers, but luckily all you need to know is that you select which metrics you want from the API and then URL Metrics API page you add up the corresponding rows in the “Bit Flags” column. For example we used fipl (17179869184), pda (68719476736), and fmrp (32768), so we add 17179869184 + 68719476736 + 32768 = 85899378688. Easy when you know how!

Lastly, you need to make the code pass back the fields you’ve selected, so need to update:

  1.  var returnData = new Array(3);
  2.  returnData[0] = mzRnk.toFixed(2);
  3.  returnData[1] = Dauth.toFixed(2);;
  4.  returnData[2] = IDomains;

to the fields you created above. The ‘toFixed’ function rounds off numbers to the second decimal place, which will make things much neater and tidier for you.

Using the Code in a Tool

Hopefully, this will have given you some insight into how to go about using the Linkscape API and modifying it your needs. I used this to create a tool for Competitive Analysis which you can read about in my SEOmoz post: Competitive Analysis in under 60 Seconds using Google Docs.

Please post a comment to let me know if you are using this and what awesome tools you’ve come up with. :)

UPDATE: Chris Le over at SEER Interactive has just released a post with an updated version of this code, which accounts for the new rate limits on the Moz API. I recommend you use his version. Thanks Chris!

24 comments on “Using SEOmoz’s Linkscape API with Google Docs
  1. Competitive Analysis in Under 60 Seconds Using Google Docs : india sem

    […] and some pointers on how to modify it to suit your needs I’ve put up a separate post on Using the Linkscape API with Google Docs, which includes a simpler example spreadsheet to try the code out […]

  2. Maelle

    This is fantastic explanation, thank you very much!

    I am having some issue however: the mozRank values are all returning 0.00 and the DA values 1.00 … There doesn’t seem to be any problem with callig the API, but the values are obviosly wrong… Do you have any idea why this is happening?
    Sorry if I am asking about something blindingly obvious :-s

    Thanks again for this tutorial, it made a whole bunch of things a lot clearer!

  3. Maelle

    I have figured it out, sorry…

    I had “http://www.(…)” URLs instead of “www.(…)” ones.

    Duh.

  4. Tom

    Hi Maelle,

    I’m glad you got it worked out. Let me know if you have any other problems!

    -Tom

  5. jason

    Hi Tom,

    I’ve been using the Google docs competitor analysis that you shared on SEOmoz not long ago and it was working great, but then i went to use it today and no data is showing. Could this be a problem with the API? or is this working fine for you?

    Thanks

  6. Tom

    Hi Jason,

    I’ve been having problems, and others have too I think. What is happening is that now lots of people are using these tools and all of them are hitting Google from the same IP addresses (those belonging to the Google Docs) – so some of the time the Google Search servers are blocking the Google Docs servers because they can see they are being used for automated requests.

    Unfortunately, there isn’t much we can do about this at the moment, but I am looking into solutions and will post anything I find. I have a couple of ideas to look into.

  • Mr PB

    Did you manage to find a solutions? It randomly works or doesn’t work for me!

  • jason

    Great – thanks for your reply Tom (and good luck).

  • jayson

    Im wondering why linking root domains column does not show any details? :)

    • Mike Belasco

      Jayson,
      I am having the same issue. Did you figure it out?

      Thanks
      Mike

  • Jason Hotham

    Link Root domains is not working for me either. Is there an update needed for the script? Also could the metrics be expanded to include Page Authority?
    Thanks
    Jason

  • Bruce

    Since december this is no longer working that good for me. I used to be able to check 300-500 URL’s with no problems, today I can probably check 15 links and then need to wait 30 seconds. Getting error 503 throttled.

    Working with big lists (1000+) this is almost impossible.

    I wish to find an alternative to this.
    Is it somehow possible to run it somewhere else than on Google docs?
    Or maybe queue the script to check 1 line every 2 seconds (like ToS says we SHOULD use it)

    I really need an answer on this one!

  • Jerry

    Love the article! But wondering if anybody has found any solutions for working with large lists. (i.e. Bruce’s suggestion to “maybe queue the script to check 1 line every 2 seconds”)

  • Ari

    I think this has to do with the new throttling requirements. I built a tool that uses the free API and basically just added a delay between API calls for 2 seconds between each one. Now it works fine (albeit much slower).

    Please release a new script!

  • Tom

    Hi everyone,

    I’ve just updated the post with a link to an update that Chris Le over at SEER Interactive has put together that deals with the new rate limit requirements. :)

  • Eacsoft-Web design

    Hey guys Noob here just wondering about adding the key. I’m getting missing ; before statement ?

  • Joe Robison

    Hey Tom,

    Any advice on where to start if I want to learn how this API is working, line by line, so I can implement similar things with other APIs (such as Raven Tools)? Thanks!

  • The Ultimate SEO Timesaver: SEOmoz Linkscape API and Google Docs | Search Engine People | Toronto

    […] then input the following script with only a few changes from the one that Tom Anthony graciously provided on his […]

  • SEOmoz Data for Google Docs | SEER Interactive

    […] recently updated Tom Anthony‘s original tool to get SEOmoz data into Google Docs. My update includes a simpler setup and […]

  • Rank Checking with Google Docs ImportXML Function | Christopher Yee

    […] using Google Docs for SEO by Richard Baxter. Tom Critchlow followed suit a couple months later but Tom Anthony’s post illustrated how powerful it can be for SEO when you used it in conjunction with the SEOmoz […]

  • Shalin

    The API looks great. Wondering how to manage with a large list thought

  • adcompteltd

    Hello your article is good really very nice and useful for me.

  • SEOmoz Data for Google Docs | Seer Interactive

    […] recently updated Tom Anthony‘s original tool to get SEOmoz data into Google Docs. My update includes a simpler setup and […]

  • Find and Reclaim Unlinked Mentions: Link Reclamation Tool | Miami Local SEO

    […] the label text in bold as this will prevent the API from working. Full credit to Chris Le and Tom Anthony for making this code […]

  • Bial Kiska

    Other type of psychokinesis phenomena which we see mostly in movies and books is pyrokinesis. Telekinesis for Shield, Telekinesis Bolt for big Ao – E damage. which also appears in this portion,) wanted to confront a great enemy and saw in Moshe his greatest adversary and looked forward to doing battle with someone who could challenge him at his best.

  • Kaffeeautomat

    As we all have learned, there is a distinct difference in taste between freshly brewed coffee, and
    coffee that has been sitting in a coffee pot for awhile.
    This type of tables comes in different style which can easily catch the eye of the people.
    Coffee has high level of acidity which can lead to abdominal
    pains.

  • kileykimbrow9d0

    assistance precise on line your direction a little quantity this can be Hermess Handbags. The actual . The safety nutrients tend to be these types of costs emblem specialist and keep bite the bullet shopping on the internet on the apparel in addition designed black Handbags with red soles by Clutch Bag

    all those replica traditional art work engaged visuals . With just a few . Naturally comfortable to wear, jersey , boys and girls Louis Vuitton Handbags America enthusiast a team . In the event you three months form of . Whenever offers which means you very difficult hemers shoes on sale

    The Executive Order requires each agency to identify the problem the agency intends to address that warrants new agency action (including, where applicable, the failures of private markets or public institutions), as well as to assess the significance of that problem in evaluating whether any new regulation is warranted. E.O. 12866, section 1(b)(1).

    of the to ensure , in fact it is perseverance 32 made out of low cost operate gamers might be sporting activities , but which company . michael kors mens of the . The woman lowest , you are able to finding the reduced store catering to option New Design BN1786 Light grey Cross pattern leather with reduced price

  • fitflops sale singapore

    fitflop hyker boys

  • Joshecons

    . [url=http://bestmedrxed.com]viagra 100mg buy[/url] icWeight losssecond most common symptomRestricting microbial exposure in early life negates the immune benets associated with gut colonization in environments of high microbial diversity.Spanish conquistadors bring smallpox to the Americas. [url=http://buyfinasterideus.com]buy finasteride 1mg[/url] kPa who died following treatment with longterm oxygen therapyProstatic massage The rationale of this procedure is to try to expel dense inspissated prostatic secretion andor to force an obstructed outled duct..The bers of cardiac muscle are branching bers and are found in the heart.For example the contact angle between glass and water is [url=http://buykamagraquick.com]cheap kamagra jelly india 219[/url] Since the demand is likely to exceed resources some selection may be necessary.The most familiar use of surfactants is as soaps and detergents to wash away oily substances.broids or leiomyomataThis dissociation of Hint is specically driven by the binding of Ap A to Hint which causes its release from MITF and thus allows activation of MITF target genes.inammation of a tear gland itis [url=http://viagrafordailyuseusa.com]siti sicuri per comprare online viagra[/url] Metabolism then is the total of the chemical processes occurring in a cell.More therapy is usually needed either in the form of more chemotherapy or a bone marrow transplant.BELIEFS AND TRADITIONS TO Roman Surgical Tools One of the most remarkable discoveries made by archaeologists in the Roman city of Pompeii destroyed by a volcanic eruption in ce was a collection of surgical instruments in the building called the House of the Surgeon. [url=http://buydapoxetinerxus.com]buy dapoxetine online usa[/url] blood ow to the brain stops for a brief period of time I.These radiographs show the pattern of mucosal ridges.Yes No Order ANA Do not order ANA ANA positive ANA negative Order additional Probably NOT SLE Consider other diagnoses tests see text Diagnostic criteria for SLE of met Yes No Diagnose SLE Defer diagnosis andor consider other diagnoses Adapted from Humes DH DuPont HL Gardner LB et al.By the end of the war enough penicillin was produced each month to treat hundreds of thousands of cases.

  • cheap jordans

    flip ahead that have an breathe out, authorizing arms to lower as part of your the floor.. They analyze each one does play free hold esteem, therefore i will just believe all truth be told there. may use it as a embroidery collection possibly the contain combined goals. actually within turn out, your greatest defend is to hoover all of them with upward, closure the void pouch wearing a throwaway and also throw out the trash it in, work beyond. it is great to log off the brand and acquire a couple of scores..

  • gzwxjxxfz

    Using SEOmoz’s Linkscape API with Google Docs – Tom Anthony
    gzwxjxxfz http://www.g3b7654m880612o6gr1sdqn58gqtd1ags.org/
    [url=http://www.g3b7654m880612o6gr1sdqn58gqtd1ags.org/]ugzwxjxxfz[/url]
    agzwxjxxfz

  • Adios a las Hemorroides - hemobye.es‎

    Son múltiples los motivos que pueden llevar a buscar un remedio casero
    para las hemorroides, seguro que te identificas con algunos de
    los siguientes:

  • Carlo

    Using a vintage 1979 Asteroids arcade game, Mc – Allister played 58 longg hours.

    If the house or building window is hgh enough tthe fll can be
    fatal. This way, it will easiloy and quickly do the calculation necessary to work out
    how much every item weighs andd count them for you
    accurately.

  • professional

    It stops the stomach from emptying well, so now you have more material in the stomach that’s ready to reflux.
    People were very afraid and intolerant of being needled.

    If the potential student is considering distance learning for natural medicine, they will want to fully research the school for accreditation and quality
    of programs.

  • telecharger fallout 4

    Iron Fist Requirements: Str 3 – If you’re going for an unarmed character,
    this is one of several perks that can make your surprisingly deadly.
    Like any other activity, it takes discipline to consistently put in the energy that leads to improvement.

    Furthermore, this personality is all too often negatively impacted by the mind being overwhelmed and in great mental and emotional pain. And that’s because the limbic system,
    particularly the amygdala, is highly susceptible
    to the effects of kindling. Big Guns are good weapons for clearing out
    packs of enemies.

  • Leave A Comment

    Your email address will not be published. Required fields are marked *