Does anyone have an example of using the Moz API with curl in bash?
-
Does anyone have an example of using the Moz API with curl in bash?
-
The link metrics documentation can be found here: https://moz.com/help/guides/moz-api/mozscape/api-reference/link-metrics
Great example for url-metrics!
-
However, what is the API call for getting backlinks?
-
Anytime!
-
sweet! thanks! it works! here is my example for anyone else:
#!/bin/bash
access_id="xxxxxxx"secret_key="xxxxxxxxxxxxxx"
The number of external links to the URL, including nofollowed links
External links: 549755813888 ued
The number of external links to the subdomain, including nofollowed links
External links to subdomain: 140737488355328 fed
The number of external links to the root domain, including nofollowed links
External links to root domain: 2251799813685248 ped
searchurl=$1
echo "Checking backlinks for ["$searchurl"]"
endpoint="lsapi.seomoz.com"call="/url-metrics/${searchurl}%2fCols=1073741825"
call="/url-metrics/${searchurl}%2fCols=549755813888"
timenow=$(date +%s)
timeend=$(( ${timenow} + (606024) ))
stringToSign=${access_id}$'\n'${timeend}
signature=$(echo -n "${stringToSign}" | openssl dgst -sha1 -hmac "${secret_key}" -binary | base64)
signature=$(echo ${signature} | sed 's/+/%2B/g;s/=/%3D/g')http://lsapi.seomoz.com/linkscape/url-metrics/moz.com%2Fblog?Cols=4&AccessID=member-cf180f7081&Expires=1225138899&Signature=LmXYcPqc%2BkapNKzHzYz2BI4SXfC%3D
http://lsapi.seomoz.com/linkscape/url-metrics/moz.com%2FCols=1073741825?AccessID=mozscape-9d88c16268&Expires=1476310241&Signature=Nuy5h4bV5Gkyw5s2X09E9WJ3sGQ%3D
for i in {1..250}; do
curl "http://lsapi1.seomoz.com/linkscape/links/10.portal.athenahealth.com?Filter=external&SourceCols=133982846973&TargetCols=133982846973&Sort=page_authority&AccessID=${access_id}&Expires=${timeend}&Signature=${signature}&Scope=page_to_domain&Limit=5&Offset=$((i100))&"
done| tr "}" "n" | perl -pe "s/[][]//g" | perl -pe "s/,{//g" | perl -pe "s/"[^"]"://g" | perl -pe "s/^{//g" >> output.csv
url="http://$endpoint/linkscape$call?AccessID=${access_id}&Expires=${timeend}&Signature=${signature}"
echo "Calling Moz API with ["$url"]"
curl $url
echo -
Hi Carl
We do not have documentation but here is an old post that should work:
https://www.distilled.net/blog/seo/rapid-protoyping-with-the-seomoz-api/
Hope this helps!
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Moz Update
Hi, in the past we could see the next Moz update in https://moz.com/products/api/updates, but i can´t see it anymore there, has been changed to another place?
API | | Agenciaseomadrid0 -
Moz Not Accounting for Google Tags
The main problem I have is that the most serious issues facing my site have been dealt with using Google Tags, but Moz doesn't take this into account (this has been verified by a Moz employee) so I can't get an accurate account of what crawl issues need fixing and which ones are resolved. Does anyone know a way to make Moz Tools account for Google Tags?
API | | moon-boots0 -
MOZ Bar recognizes a link as No-Followed even when there's no evidence of nofollow nor external tag
Hi! I've seen that the Moz bar recognizes some links as NoFollowed, even when technically are followed.
API | | Gaston Riera
One example of that is this page: https://wiki.python.org/moin/PythonTraining I've attached an image to clarify.
The link is just: <a class="https" <span="">href="https://rmotr.com"> there is no evidence of no following tag (such as external, nofollow, etc). Thanks!
GR.</a> <a class="https" <span=""></a>2e3b9c02fe.png 1513d1b95d.png0 -
Keywords API
Does MOZ offer any statistics/data about keywords through the API? I didn't see anything in the documentation... Thanks! Justin
API | | Campaignium0 -
3 result limit to Top Pages API call
I am using the MOZ API to make calls for the top pages for a particular URL. However, when I pass in any limit value greater than 3 the API only returns 3 results. I have even tried to put in URLs like 'www.moz.com' and still only 3 results. Sample call to the API below: http://lsapi.seomoz.com/linkscape/top-pages/www.moz.com?AccessID=member-xxxxxxxxx&Expires=1419020831&Signature=xxxxxxxxx&Cols=2052&Offset=0&Limit=50
API | | solodev0 -
Seo moz api request problem [401 error_message Your authentication failed]
Hello Team, I have moz pro account. I'm getting following error for seomoz call using your API: {"status":"401","error_message":"Your authentication failed. Check your authentication details and try again. For more information on signed authentication, see: http://apiwiki.moz.com/signed-authentication"} The link that we are using is:
API | | eBrandz
http://lsapi.seomoz.com/linkscape/url-metrics/ And following bits are requested during the call: 68719476736 34359738368 32 2048 16384 The error is intermittent. It comes and goes. There were no issues with results 3 days ago. I suddenly started getting this error. Could you please investigate into it and let me know the cause of issues and its correctiveness. It will great if you can provide us a support email Id for immediate response. Thanks,0 -
How to best use MOZ api?
i love the idea of the api - but need a tool to access it. having seen the seogadget excel addin, but unable to use it with my MAC. Do you have a recommendation for using api without writing my own code? Thanks, in advance!
API | | robertdonnell0