<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: IT Cathay Pacific</title>
    <description>The latest articles on DEV Community by IT Cathay Pacific (@cathaypacificflights).</description>
    <link>https://dev.to/cathaypacificflights</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2823683%2F1cecd498-b3ad-4adc-8286-15d3e160b300.png</url>
      <title>DEV Community: IT Cathay Pacific</title>
      <link>https://dev.to/cathaypacificflights</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cathaypacificflights"/>
    <language>en</language>
    <item>
      <title>API Access to Moz Domain Authority &amp; Page Authority</title>
      <dc:creator>IT Cathay Pacific</dc:creator>
      <pubDate>Thu, 06 Feb 2025 09:30:40 +0000</pubDate>
      <link>https://dev.to/cathaypacificflights/api-access-to-moz-domain-authority-page-authority-c9a</link>
      <guid>https://dev.to/cathaypacificflights/api-access-to-moz-domain-authority-page-authority-c9a</guid>
      <description>&lt;p&gt;To get the Domain Authority (DA) and Page Authority (PA) from Moz's API and display it on a webpage, you'll need to use their Mozscape API. You can get the DA and PA of a domain by making an API request.&lt;/p&gt;

&lt;p&gt;Here’s how you can set up a simple webpage with HTML, CSS, and JavaScript that interacts with the Moz API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Moz API Access:&lt;/strong&gt; You need to sign up for Moz and get an API key: Moz API Sign Up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. API Endpoint:&lt;/strong&gt; The Moz API provides an endpoint for retrieving link metrics like DA and PA.&lt;br&gt;
For this example, we'll assume that you have the Moz API credentials (Access ID and Secret Key) to access the Mozscape API.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML + CSS + JavaScript Example:
&lt;/h2&gt;

&lt;h2&gt;
  
  
  HTML (index.html)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
  &amp;lt;title&amp;gt;Moz API DA/PA Checker&amp;lt;/title&amp;gt;
  &amp;lt;link rel="stylesheet" href="styles.css"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;div class="container"&amp;gt;
    &amp;lt;h1&amp;gt;Check Domain Authority (DA) &amp;amp; Page Authority (PA)&amp;lt;/h1&amp;gt;
    &amp;lt;input type="text" id="url-input" placeholder="Enter URL" /&amp;gt;
    &amp;lt;button onclick="getMozData()"&amp;gt;Check DA/PA&amp;lt;/button&amp;gt;

    &amp;lt;div id="result"&amp;gt;
      &amp;lt;p id="da"&amp;gt;Domain Authority (DA): N/A&amp;lt;/p&amp;gt;
      &amp;lt;p id="pa"&amp;gt;Page Authority (PA): N/A&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;

  &amp;lt;script src="script.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CSS (styles.css)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  font-family: Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  background-color: #f4f4f9;
}

.container {
  text-align: center;
  padding: 20px;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  width: 80%;
  max-width: 400px;
}

input {
  padding: 10px;
  width: 80%;
  margin-bottom: 20px;
  border-radius: 5px;
  border: 1px solid #ccc;
}

button {
  padding: 10px 20px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

button:hover {
  background-color: #0056b3;
}

#result {
  margin-top: 20px;
}

#result p {
  font-size: 18px;
  font-weight: bold;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  JavaScript (script.js)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const MOZ_ACCESS_ID = 'YOUR_ACCESS_ID';  // Replace with your Moz Access ID
const MOZ_SECRET_KEY = 'YOUR_SECRET_KEY'; // Replace with your Moz Secret Key

// Function to fetch DA/PA data using Moz API
async function getMozData() {
  const url = document.getElementById("url-input").value.trim();

  if (url === "") {
    alert("Please enter a valid URL.");
    return;
  }

  const endpoint = `https://lsapi.seomoz.com/linkscape/url-metrics/${encodeURIComponent(url)}`;

  const headers = new Headers();
  const credentials = btoa(`${MOZ_ACCESS_ID}:${MOZ_SECRET_KEY}`);

  headers.append("Authorization", `Basic ${credentials}`);

  try {
    const response = await fetch(endpoint, { headers });
    const data = await response.json();

    if (data.status === "ok") {
      document.getElementById("da").textContent = `Domain Authority (DA): ${data.pda}`;
      document.getElementById("pa").textContent = `Page Authority (PA): ${data.page_authority}`;
    } else {
      alert("Error fetching data from Moz API");
    }
  } catch (error) {
    console.error("Error:", error);
    alert("Failed to fetch DA/PA data. Please try again.");
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Explanation:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;HTML:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A simple input box where the user can enter the URL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A button to trigger the action.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A result section that will display the Domain Authority (DA) and Page Authority (PA).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;CSS:&lt;/strong&gt;&lt;br&gt;
Simple styling to make the page look clean and easy to read. It centers everything and adds some padding to the elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The getMozData function uses the fetch API to make a request to the Moz API endpoint and fetch the DA/PA of the URL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Moz API requires authentication via Basic Authentication using your Access ID and Secret Key (encoded in base64).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The fetch request is sent to Moz's endpoint (&lt;a href="https://lsapi.seomoz.com/linkscape/url-metrics/" rel="noopener noreferrer"&gt;https://lsapi.seomoz.com/linkscape/url-metrics/&lt;/a&gt;) with the URL as a query parameter.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the request is successful, the DA and PA values are displayed in the result section.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Use:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Replace YOUR_ACCESS_ID and YOUR_SECRET_KEY in the JavaScript file with your actual Moz API credentials.&lt;/li&gt;
&lt;li&gt;Open the HTML file in a browser.&lt;/li&gt;
&lt;li&gt;Enter a URL in the input box and click the "Check DA/PA" button to get the domain authority and page authority.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Notes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Moz's API has rate limits, so you might want to be cautious about how often you request data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ensure you don't expose your Moz credentials on a public site. This example is for demonstration purposes, and sensitive information like API keys should be handled more securely in production environments (e.g., using server-side code). &lt;a href="https://cathaypacificflights.com/" rel="noopener noreferrer"&gt;Cathay Pacific&lt;/a&gt;: If more codes are required then contact us.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>css</category>
      <category>javascript</category>
      <category>html</category>
    </item>
  </channel>
</rss>
