Grabbing SEOmoz Metrics with F#

  • 0
  • June 30, 2011
Julian Kay

Julian Kay


I’m regularly tasked with quickly getting some statistics about a website, and being the geeky developer I am – I tend to use my F# scripts to gather this data. This time, I’m going to show you how you can use a similar method to my previous post ‘Grabbing Page Titles with F#‘ to grab metrics from SEOmoz.

To try out this code, you should already have an idea what F# is and how it works. If not, check out the F# Developer Center on MSDN.

Simply put, SEOmoz are a company which provide a rich set of APIs for gathering intelligence on links. You can get access to some of their data by using Open Site Explorer or by getting an SEOmoz account and trying out their API.

Below, I show you how you can use F# Interactive or write an F# script file (.fsx) to gather data from SEOmoz and display it to the screen. SEOmoz returns super-lightweight JSON strings which will need to be deserialized, so we make a reference to the excellent Json.NET library, which you’ll need to include at the top of your script.

As you can see above, we have a set of small functions which take in the details of the site you want to check (and your SEOmoz account information), then returns you a Metrics object which can then be accessed any way you like. Note that SEOmoz URL Metrics API is capable of returning much more data than this, be sure to check out the API reference for a full list of everything you can capture about a URL.

We can test this out simply by calling this function and printing the data as shown here…

Which will return the results..

So there you have it, simple F# programs can be used to call the SEOmoz API to provide super-fast metrics about a URL. I recently wrote about running F# script files with PowerShell and Vim on my personal blog. Be sure to check it out if you want to turn it up to geek factor 11.

Free of charge. Unsubscribe anytime.