The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. API
    4. 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?

    API
    6 2 462
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • silvacarl
      silvacarl last edited by

      Does anyone have an example of using the Moz API with curl in bash?

      1 Reply Last reply Reply Quote 0
      • DavidLee
        DavidLee last edited by

        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!

        silvacarl 1 Reply Last reply Reply Quote 0
        • silvacarl
          silvacarl @DavidLee last edited by

          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

          silvacarl 1 Reply Last reply Reply Quote 1
          • DavidLee
            DavidLee last edited by

            Anytime! 🙂

            1 Reply Last reply Reply Quote 0
            • silvacarl
              silvacarl @silvacarl last edited by

              However, what is the API call for getting backlinks?

              DavidLee 1 Reply Last reply Reply Quote 0
              • DavidLee
                DavidLee @silvacarl last edited by

                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!

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                • How many domain i can do bulk check using API ?
                  MinnieCarnahan
                  MinnieCarnahan
                  0
                  3
                  61

                • What use plugin wordpress for MOZ?
                  samantha.chapman
                  samantha.chapman
                  0
                  2
                  136

                • Do you fetch website titles from paid api https://moz.com/help/guides/moz-api/mozscape/api-reference/url-metrics?
                  dave.kudera
                  dave.kudera
                  0
                  4
                  98

                • MOZ API - metadata permission error
                  DavidLee
                  DavidLee
                  1
                  2
                  913

                • MOZ API - Search Visibility
                  thomas.deruiter
                  thomas.deruiter
                  0
                  3
                  223

                • Moz rank tracker API
                  samantha.chapman
                  samantha.chapman
                  0
                  2
                  386

                • Use of Moz with non-latin characters
                  MattRoney
                  MattRoney
                  0
                  5
                  241

                • Cannot get the API to work when using an EC2 server
                  csandrew
                  csandrew
                  0
                  3
                  124

                Get started with Moz Pro!

                Unlock the power of advanced SEO tools and data-driven insights.

                Start my free trial
                Products
                • Moz Pro
                • Moz Local
                • Moz API
                • Moz Data
                • STAT
                • Product Updates
                Moz Solutions
                • SMB Solutions
                • Agency Solutions
                • Enterprise Solutions
                • Digital Marketers
                Free SEO Tools
                • Domain Authority Checker
                • Link Explorer
                • Keyword Explorer
                • Competitive Research
                • Brand Authority Checker
                • Local Citation Checker
                • MozBar Extension
                • MozCast
                Resources
                • Blog
                • SEO Learning Center
                • Help Hub
                • Beginner's Guide to SEO
                • How-to Guides
                • Moz Academy
                • API Docs
                About Moz
                • About
                • Team
                • Careers
                • Contact
                Why Moz
                • Case Studies
                • Testimonials
                Get Involved
                • Become an Affiliate
                • MozCon
                • Webinars
                • Practical Marketer Series
                • MozPod
                Connect with us

                Contact the Help team

                Join our newsletter
                Moz logo
                © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                • Accessibility
                • Terms of Use
                • Privacy