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 for discovered and lost linking domains
Hello, Currently you do not have discovered and lost metrics available via the Links API, maybe there are some workaround to get this metrics? For us, it is very important to use API, or calculate it some mathematics way. Thank!
API | | OlegKireyenka0 -
What is the metric to check link state and link type for MOZ API ?
Kindly do not share the website url related to url and link metrics,instead of mention the correct metric for link state and link type. Thanks!
API | | rogerdavid0 -
Integrating Moz with DashThis
I'm trying out DashThis as a way to visualize data for clients with whom we do a combo of SEO, PPC, and SEM work. I like the main Moz Pro campaign dashboard page for distilling top-level information and the rankings page for tracking keyword ranks. In an ideal world, I'd love to be able to sort replicate these within DashThis. I see that DashThis does integrate with Moz but looking at the Mozscape API documentation I couldn't tell if this type of integration is possible in DashThis. I realize this is a super specific question, but I thought I'd ask the community if this integration is possible or if I have more limited range of options.
API | | TheKatzMeow0 -
"403 Forbidden" is they will be displayed in the "API"
Nice to meet you.
API | | yamayamax
Although the future API of the question of "URL Metrics", I want you to forgive me English is very immature thing. I'm very troubled now.
If you call the "API" in the manner described below, such PHP of the program, "403 Forbidden" is the result.
Because the information when you visit the URL directly is displayed, we suspect the PHP of the problem.
About the cause, it will be saved in a very and Nowak advice.
Whether Thank you. code $accessID = "<removed for="" privacy="">";
$secretKey = "<removed for="" privacy="">";
$expires = time() + 300;
$SignInStr = $accessID. "\n" .$expires;
$binarySignature = hash_hmac('sha1', $SignInStr, $secretKey, true);
$SafeSignature = urlencode(base64_encode($binarySignature));
$objURL = "http://www.google.com";
$flags = "103079217188";
$reqUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/".urlencode($objURL)."?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$SafeSignature;
$opts = array(CURLOPT_RETURNTRANSFER => true);
$curlhandle = curl_init($reqUrl);
curl_setopt_array($curlhandle, $opts);
$content = curl_exec($curlhandle);
curl_close($curlhandle);
$resObj = json_decode($content); //decode the json object and fetch results
echo $reqUrl . "
";
echo "Domain Authority : " . $resObj->{'pda'};
echo "Page Authority : " . $resObj->{'upa'};
?>
------------------------------------------------------------------------------------</removed></removed>0 -
API for crawl reports?
Hello, I'd like to know if moz api is able to provide me the crawl reports. We're currently developing a simple crawl report analysis/parsing tool and after analysing the API we weren't able to find a function that could return us wether the excel file or the report results. Is there any way? Thank you very much.
API | | PLOT_PT0 -
Is it possible to send a string/id to an api call and return it?
I am integrating your mozscape API into a project of mine and I am in need of seeing if I can send and return a variable with an associated call. For instance when I am sending some batch URL's I am requesting the [upa] and [pda] back. I am also requesting the [uu] (canonical URL) but it always seems to come back blank. So the issue I am having is if I send a batch of urls to the API how do I know how to associate a [upa] or [pda] with a link? My thoughts are if I could send a ID with a link and return that ID back then I know how to associate the [upa] or [pda] with that particular link. Anyone know?
API | | cbielich1 -
How to pull metrics from API for a top 100 list
I'm working on a top 100 list for my industry and need a way to pull DA for the list of blogs and then sort them in descending order until it can pull other metrics (Alexa and follower count). Right now I am doing the above manually and was trying to hunt for a way for the table to update on a set date. any help / guidance appreciated
API | | ArfanB0