Mozscape’s API is a little daunting to use with the amount of valuable information it can offer. Here’s a simple PHP class that allows you to easily access your site’s SEO metrics using the Mozscape API. A major benefit to the Mozscape API PHP Class is the ability to return detailed information on the response fields Mozscape provides.
- Mozscape URL Metrics API
- Mozscape Top Pages API
- Mozscape Metadata API Calls
- Mozscape Response Fields
- Mozscape Attribution Links
It’s pretty simple to use this class. Currently it’s pretty limited to the data it can provide in relation to what’s available through Mozscape’s API, but I do have plans on adding the rest of the available APIs later on.
That’s it, pretty simple huh?
Here’s more detailed information on how to use the class. If you have any questions or suggestions, I’d love to hear them.
Mozscape URL Metrics API
To access the Mozscape URL Metrics API, you just need to provide the URL you want to retrieve data for and the type of data you want (the total sum of Bit Flags).
Mozscape Response Fields
responseFields($field, $return_value = '')
This is a great helper to get information on the various response fields that the Mozscape API provides, including the bit flag values, user-friendly names, slugs, and descriptions! See more information on Mozscape’s Response Fields here: http://apiwiki.seomoz.org/response-fields.
Mozscape Top Pages API
topPages($url, $offset = 0, $limit = 1000, $bits = 4)
This paid call returns the metrics about many URLs on a given subdomain. The top pages call can be accessed by the API call top-pages. A set of metrics can be requested by indicating them as bit flags in the
$bits parameter. A page of urls with associated metrics is returned. The start record of the page can be specified using the
$offset parameter. The size of the page can by specified using the
$limit parameter. URLs are currently sorted by number of linking root domains.
A maximum of 1000 records can be retrieved per call. Limits over this value will result in a 400 Bad Request or 500 Internal Error response.
Currently only 10,000 pages may be retrieved using top-pages calls, in at least 10 calls.
See more on Mozscape’s Top Pages API here: http://apiwiki.seomoz.org/top-pages-api
Mozscape Required Attribution Link
attributionLink($type, $size, $img_dir = 'img/mozscape/')
This is good to use to stay compliant with the required Mozscape API’s attribution links. Provides easy output using their approved logo or icon with the required link.
- Created a changelog file
- Added an error message if the Curl request to the Mozscape API failed
- Added the Mozscape Metadata API Calls
- Added the Mozscape Top Pages API