I’m regularly tasked with quickly getting some statistics about a website, and being the geeky developer I am – I tend to use myF# 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 library which isfree on itunes, which you’ll need to include at the top of your script.
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.
So there you have it, simple F# programs can be used to call the SEOmoz API to provide super-fast metrics about a URL.