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
-
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 -
API - Row Limit Question
Hi, I'm new to using Moz, and have just got a "Low volume" API account set up. My question is, because ive not yet reached my maximum "Rows per month" limit, what behaviour happens when i reach it? Do i get an error code, if so what, and whats the status code. If not, does my account keep downloading the rows and i get charged extra (in accordance with the cost of the additional rows)? Or is the whole additional rows think like a bolt on? Basically i want to make sure i dont get charged extra each month, and i need the status code returned to handled this in my app. I couldnt see anything explicit in the documents. Cheers
API | | MattHopkins0 -
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 much attention should I pay to Moz's DA/PA?
Hola! I've been optimising a site since October and our hard work has yielded a sizeable increase in organic traffic, revenue, quality, relevant links and Search Metrics scoring since commencing the campaign. After yesterday's Moz update, the DA has dropped slightly and a number of pages' PAs have dropped significantly (i.e. from 27 to 17). So here are my questions: My 'white hat' optimisation is clearly working. The site is enjoying more than 100% year-on-year increase in organic traffic and we're currently pulling in more organic visitors than ever before. Why is Moz's score not reflecting this? Some of the pages that have seen sizeable PA drops have had their URLs changed since the last Moz update. For example, I've optimised a URL from www.mysite.com/cases-covers to www.mysite.com/phone-cases to coincide with search volumes. I've added optimised content to this page too, but the PA has dipped from 27 to 17. A 301 redirect has been correctly added, and this is evident by a PA of 17 and not zero, which is what a brand new page would have. Am I paying too much attention to Moz's scores? It's a bit disheartening to see a drop after a lot of hard work. However, I guess the only thing that really counts is an increased volume of search traffic and revenue, right? Cheers, Lewis
API | | PeaSoupDigital0 -
Integrate Piwik data with Moz instead of Google Analytics?
Hello everyone, The company I work for had Google Analytics for all of our websites, dating back at least 4 years. Because of our email infrastructure, we accessed Analytics through a temporary account. Now this account worked fine for 4 years, until over the last two weeks where at some point Google deleted that account, and the Analytics connected to it. I've had no response from Google regarding this, but that's by the by. Anyway, I've made the decision to bring the analytics in house and hold the data ourselves. I've chosen Piwik for this, and it's been running fine for the last few days. However, I know Moz integrates with Google Analytics, but at the moment this is useless to me. Is there a way, or are there any plans, to integrate Piwik with Moz? If not, what benefits will I lose if I discontinue using Google Analytics with Moz?
API | | theponyclub0 -
API: General information URL on path level
Is it possible to get general information (refdomains, mozrank etc.) out of the API on path level? If so, what is the best way to do this? Example www.test.com/folder/ -> Combined data (for example, total refdomains etc) for all URL’s indexed by Moz that include www.test.com/folder/ -> like www.test.com/folder/item/page.html and www.test.com/folder/page2.html
API | | MerkleNederland0