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.
Features
- Mozscape URL Metrics API
- Mozscape Top Pages API
- Mozscape Metadata API Calls
- Mozscape Response Fields
- Mozscape Attribution Links
Implementation
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?
Documentation
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
urlMetrics($site_url, $sum_of_bit_flags)
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: https://moz.com/help/guides/moz-api/mozscape/api-reference/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.
Change Log
Version 1.1
- 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
2 comments on “Mozscape API PHP Class”.
# Apr 5, 2020
Where is class.MozscapeAPIClass.php ?
# Feb 19, 2015
Good job. Thank you.
All comments posted on 'Mozscape API PHP Class' are held for moderation and only published when on topic and not rude. Get a gold star if you actually read & follow these rules.
You may write comments in Markdown. This is the best way to post any code, inline like `<div>this</div>` or multiline blocks within triple backtick fences (```) with double new lines before and after.
Want to tell me something privately, like pointing out a typo or stuff like that? Contact Me.