I love a challenge, especially when it comes to learning new skills. Today I’m going to show you an incredibly simple way to get your SEOmoz data straight into Excel – hopefully, my post will inspire some of you hardcore Excel junkies to go and build some new toys. What’s not to like?
Do I need to learn to code?
Not for this post. All you’ll need to do is follow the instructions, think about what you’re reading and be willing to try something new.
What do I need to know?
Well, you need to be reasonably familiar with Microsoft Excel, not advanced, just familiar. You’ll need a basic primer on simple regex (this post by Rob will do nicely) and a reasonable sense of how an API call works – check out Ben’s introduction to the SEOmoz API here. Finally, you’ll need Niel’s awesome SEO Tools for Excel.
Basically, if you can form a URI and an Excel query, we’re good to go! Here’s how:
Form a valid API call
To get a response from the SEOmoz api, you just need to form a URL. For testing purposes, forming the following URL and pasting into your browser would get a response:
Depending on the type of API access you have, you’ll get a lot of json back in your browser, like this:
Using bit flags, we can get to the data we actually want, say, links to the root domain if you have the full site intelligence API (like we do, yeah!) or juice passing links if you’re rocking the free api. Either way, it’s getting the data we care about, so check this out:
?Cols=32 is the bit flag for the external links API call. The insanely clever thing about bit flags is (are?) that, if you add the number of another bit flag to 32, let’s say, http status code (536870912) to make 536870944, you get this:
Anyway, we’re here to get API data into Excel. To get the job done, we’re going to use SEO Tools for Excel, and specifically the following functions:
You’ll need to understand
=Concatenate, and understand that “d+” in regex means “a character in the range 0-9), 1 or more times”.
Form a valid http request
If you attempt to request our API URL without authentification, you’ll get a 400 response, and obviously no data. For ages, I tried using the member ID and secret key in the request URI with no luck. Thankfully my buddy Neils taught me the
The function is designed to control HTTP requests made by SEO Tools functions, In our case, we need to use the function to authenticate with a member ID and secret key. So, the query looks like this:
BuildHttpDownloader’s output is in XML, which is used to configure the function we’re using to fetch the data, =DownloadString()
In its simplest form, the correct syntax to fetch the API output is now:
To make this work, create a cell for the api call URI (“A1”), and a cell for your BuildHttpDownloader output (“A2”). That would make your DownloadString function look like this:
And here’s what that looks like in Excel:
How good is that?! That, my friends is API output straight into Excel!
The last bit – how to extract that number
This is where the regex comes in. If you’re an actual coder, this is where you’ll tempted to mention JSON parsers and all that stuff. A JSON parser makes it easy for developers to fetch the data they need from a JSON output. There is actually a JSON parsing function in SEO Tools, so it’s perfectly possible to head down that route, and even write the results to an array. For the purpose of learning, I really wanted to extract my precious number as quickly and simply as possible. And anyway, if I give it up in one blog post, what is there left for you to work out?
So, assuming the fruits of your labour have been written to cell A3, here’s all you need to do:
And just like that, you’ll get a nice clean result for which you can add to a table, combine with data from your other tools and generally have an awesome time dreaming up ways to cook your menu of new data skills.
Image credit: DannyMCL
Danny Goodwin has created a better way to do this with the newer version of SEO Tools – check out his code here: (Very nice Dan!)