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
-
API ACCESS to COMPETITOR DATA
Is there access with any of the available API's that I may be able to show my client's keyword competitive data for them vs their competitors (The ones they specify?). Perhaps in JSON format?
API | | Digitlead0 -
MOZ API - metadata permission error
Hi there, I have a small issue using MOZ API. I cannot make successful GET request for metadata (index stats). The request looks like this: http://lsapi.seomoz.com/linkscape/metadata/index_stats?AccessID=mozscape-XXXXXX&Expires=1497442682&Signature=XXXXXX. In my most recent request, I got an error message: "Permission denied: pckgmhkomakbnflgmckhobiiojjmomjpph". Did I forget something? Signed Authentication should be OK, because it works with other endpoints, such as "url-metrics", "links" etc. Thanks in advance! Kind regards, Zoran
API | | Databox-apps1 -
Frequency of Moz page authority updates?
I have some new pages on my site, and Moz gives them a very low PA ranking. I am wondering if these scores are updated monthly or quarterly? I'm not sure how frequently to check back for updated scoring.
API | | AndrewMicek0 -
Moz Thumbs not working? @MozHelp
Hi all, I'm noticing an issue with Moz thumbs. Last night before bed, I am pretty positive I gave EGOL and Laura a thumbs up for their answers to this question. This morning I noticed there were no thumbs up for their responses. At first I thought maybe I didn't give them a thumbs up, and proceeded to thumb them again. Everything appeared to work, however after returning to the post I noticed my thumbs didn't appear to be recorded. Has anybody noticed this issue?
API | | donford0 -
Wrong answers for API request
Hi, I just recently started getting errors when using the API. The request back contains zeros for all the keys except PDA which is a new to me. Haven't changed anything in the code and the authorization seems to work fine. Is this something on my end? However, I don't get for all the requests, perhaps half of the time. Example of the return: {"fmrp":0,"fmrr":0,"pda":27.7812456171725224,"ueid":0,"uid":0,"uipl":0,"umrp":0,"umrr":0,"upa":1} Thanks in advance! /Mathias
API | | Lobtec0 -
Moz crawl error? DA & Linking domains significant drop.
Hi guys! Our site www.carwow.co.uk appears to have been punched in the face by the latest Moz update. It's claiming our #linking root domains has dropped from 225 to 135 and has subsequently hit our DA from 38 to 35. We haven't disavowed any links and our off-site strategy has been going well the past 2 months. Search performance has increased by around 15% (around 5k sessions) and rankings have improved week on week. Any idea if this is a Moz error? That's almost a 50% drop in linking root domains. Thanks, James
API | | Matt.Carwow0 -
Is Moz Pro down?
This morning, just before trying to meet with a client, I cannot access Moz Pro. Here is the page I get: This XML file does not appear to have any style information associated with it. The document tree is shown below.
API | | jessential
<error>NoSuchBucket<message>The specified bucket does not exist</message><bucketname>analytics.moz.com</bucketname><requestid>DC68738B494D30A1</requestid><hostid>r13H1pVq04vKGcKkAD9AUCTRXNdZAhUOULNwv4/TB74e0utcat2mV3PT7dXOtnuG</hostid></error> What can I do to access my information?0 -
Does any one know if there is a tool out there built with the Moz API where you can feed in a large list of URLs and get back Domain Authority?
Does any one know if there is a tool out there built with the Moz API where you can feed in a large list of URLs and get back Domain Authority? Has anyone used the API for something like this before? Thanks! Max
API | | Porch0