To integrate Replit with Moz, store your Moz Access ID and Secret Key in Replit Secrets (lock icon π in sidebar), then call the Moz Links API v2 from your Node.js or Python server using HMAC-SHA1 authentication to retrieve Domain Authority, Page Authority, and link metrics. Moz API requires a paid Moz subscription β the free account does not include API access.
Why Integrate Moz API with Replit?
Domain Authority (DA) and Page Authority (PA) are Moz-proprietary metrics that correlate with Google search rankings and are widely used in SEO auditing, link building research, and site valuations. The Moz Links API makes these metrics available programmatically, allowing developers to build tools that check DA scores at scale without manual lookup in Moz's web interface.
Integrating Moz's API into a Replit project is straightforward because the API uses standard HTTP Basic Authentication β no complex OAuth flows required. Your Access ID and Secret Key from the Moz developer dashboard are combined and base64-encoded as a Basic auth header. The API accepts simple JSON POST requests and returns metric data for URLs or domains.
Common Replit and Moz API use cases include: building a bulk DA checker that accepts a list of domains and returns their DA/PA scores, creating a link prospect qualifier that filters a list of potential backlink targets by minimum DA, building a client reporting tool that generates DA trend reports for a portfolio of client websites, and building an automated site audit tool that flags pages with low PA as candidates for internal linking improvements.
Integration method
The Replit-Moz integration calls the Moz Links API v2 (api.moz.com) from your Replit server-side code using HTTP Basic Authentication with your Moz Access ID and Secret Key. The API returns domain authority scores, page authority, spam scores, and link count metrics for any URL or domain. All calls are made server-side with credentials stored in Replit Secrets.
Prerequisites
- A Moz account with an active subscription that includes API access (Medium plan or higher)
- Moz Access ID and Secret Key from moz.com/products/api/keys
- A Replit account with a Node.js or Python Repl
- Basic familiarity with making authenticated HTTP requests
Step-by-step guide
Get Your Moz API Credentials
Get Your Moz API Credentials
The Moz Links API uses HTTP Basic Authentication with two values: an Access ID and a Secret Key. To retrieve these, log into your Moz account and navigate to moz.com/products/api/keys. You will see your Access ID (formatted like 'mozscape-XXXXXXXXXX') and Secret Key (a long hex string). These are your API credentials β treat the Secret Key like a password. Moz API access is included with paid plans: - Standard plan: limited API queries per month - Medium plan and above: higher query volumes - Enterprise: custom volumes The free Moz account does not include API access. If you do not see credentials on the API keys page, your plan does not include API access. The Moz Links API v2 base URL is https://api.moz.com/jsonrpc. It uses a JSON-RPC style POST request with HTTP Basic Auth. This differs from the older v1 API that used HMAC-SHA1 timestamp-based authentication β v2 is much simpler. Note on free DA lookups: Moz offers limited free DA lookups through their web tools, but programmatic bulk access requires paid API credentials.
Pro tip: Check your monthly API query limit in your Moz account dashboard. Each call to the Links API counts against your quota. For bulk operations, batch multiple URLs in a single request to reduce query consumption.
Expected result: You have a Moz Access ID (starts with 'mozscape-') and a Secret Key visible on the API keys page.
Store Moz Credentials in Replit Secrets
Store Moz Credentials in Replit Secrets
Click the lock icon (π) in the Replit sidebar to open the Secrets panel. Add the following secrets: MOZ_ACCESS_ID β your Access ID (e.g., 'mozscape-XXXXXXXXXX') MOZ_SECRET_KEY β your Secret Key Click 'Add Secret' for each. These values are AES-256 encrypted and never visible in your file tree or Git history. Replit's Secret Scanner also flags any patterns that look like API credentials in committed code. Access in Node.js: const accessId = process.env.MOZ_ACCESS_ID; const secretKey = process.env.MOZ_SECRET_KEY; Access in Python: import os access_id = os.environ['MOZ_ACCESS_ID'] secret_key = os.environ['MOZ_SECRET_KEY'] For HTTP Basic Auth, these are combined as: accessId:secretKey, then base64-encoded and passed in the Authorization header as 'Basic {base64string}'.
Pro tip: Test that your credentials work before building your full application: run a simple one-line test request and verify you get back actual metric data rather than a 401 or 403 error.
Expected result: MOZ_ACCESS_ID and MOZ_SECRET_KEY appear in the Replit Secrets panel and are accessible via process.env or os.environ in your code.
Query Domain Authority with Node.js
Query Domain Authority with Node.js
The Moz Links API v2 accepts POST requests to https://api.moz.com/jsonrpc with JSON-RPC formatted bodies. HTTP Basic Authentication uses your Access ID as the username and Secret Key as the password. The main endpoint for DA/PA data is the GetUrlMetrics method, which returns domain authority, page authority, root domain authority, spam score, and link counts for a URL. The Node.js code below uses the built-in fetch API (Node 18+, Replit's default) with no external packages. It handles a single URL and a batch of URLs.
1// moz-client.js β Moz Links API v2 client2const MOZ_API = 'https://api.moz.com/jsonrpc';34function getAuthHeader() {5 const accessId = process.env.MOZ_ACCESS_ID;6 const secretKey = process.env.MOZ_SECRET_KEY;7 if (!accessId || !secretKey) throw new Error('MOZ_ACCESS_ID or MOZ_SECRET_KEY not set');8 const encoded = Buffer.from(`${accessId}:${secretKey}`).toString('base64');9 return `Basic ${encoded}`;10}1112// Fetch metrics for a single URL13async function getUrlMetrics(url) {14 const response = await fetch(MOZ_API, {15 method: 'POST',16 headers: {17 'Authorization': getAuthHeader(),18 'Content-Type': 'application/json'19 },20 body: JSON.stringify({21 jsonrpc: '2.0',22 id: '1',23 method: 'data.site.metrics.fetch',24 params: {25 data: { site: url },26 limit: 127 }28 })29 });3031 if (!response.ok) {32 const err = await response.text();33 throw new Error(`Moz API error ${response.status}: ${err}`);34 }3536 const data = await response.json();37 if (data.error) throw new Error(`Moz API error: ${JSON.stringify(data.error)}`);38 return data.result;39}4041// Fetch metrics for multiple URLs in one request42async function getBulkMetrics(urls) {43 const response = await fetch(MOZ_API, {44 method: 'POST',45 headers: {46 'Authorization': getAuthHeader(),47 'Content-Type': 'application/json'48 },49 body: JSON.stringify({50 jsonrpc: '2.0',51 id: '1',52 method: 'data.site.metrics.fetch',53 params: {54 data: urls.map(url => ({ site: url })),55 limit: urls.length56 }57 })58 });5960 if (!response.ok) {61 const err = await response.text();62 throw new Error(`Moz API error ${response.status}: ${err}`);63 }6465 const data = await response.json();66 if (data.error) throw new Error(`Moz API error: ${JSON.stringify(data.error)}`);67 return data.result;68}6970module.exports = { getUrlMetrics, getBulkMetrics };Pro tip: The Moz Links API v2 endpoint and method names can vary by plan. Check the official Moz API v2 documentation at moz.com/help/links-api for the exact method name and params structure available to your plan.
Expected result: getUrlMetrics('example.com') returns an object containing domain authority, page authority, spam score, and link count metrics.
Build a DA Checker API Server with Express
Build a DA Checker API Server with Express
Wrap the Moz client in an Express server to create a reusable Domain Authority lookup endpoint. This allows dashboards, internal tools, and other services to query Moz data without needing direct access to your API credentials. Install Express: npm install express Deploy as Autoscale on Replit β DA checking is an on-demand workload that benefits from scale-to-zero pricing.
1// server.js β Express DA checker using Moz API2const express = require('express');3const { getUrlMetrics, getBulkMetrics } = require('./moz-client');45const app = express();6app.use(express.json());78// GET /da?url=example.com9app.get('/da', async (req, res) => {10 const { url } = req.query;11 if (!url) return res.status(400).json({ error: 'url parameter required' });12 try {13 const metrics = await getUrlMetrics(url);14 res.json({ url, metrics });15 } catch (err) {16 console.error('Moz error:', err.message);17 res.status(500).json({ error: err.message });18 }19});2021// POST /da/bulk β { urls: ['example.com', 'another.com'] }22app.post('/da/bulk', async (req, res) => {23 const { urls } = req.body;24 if (!Array.isArray(urls) || urls.length === 0) {25 return res.status(400).json({ error: 'urls array required in request body' });26 }27 if (urls.length > 50) {28 return res.status(400).json({ error: 'Maximum 50 URLs per bulk request' });29 }30 try {31 const results = await getBulkMetrics(urls);32 res.json({ count: urls.length, results });33 } catch (err) {34 console.error('Moz bulk error:', err.message);35 res.status(500).json({ error: err.message });36 }37});3839const PORT = process.env.PORT || 3000;40app.listen(PORT, '0.0.0.0', () => {41 console.log(`Moz DA checker running on port ${PORT}`);42});Pro tip: Limit bulk requests to a reasonable batch size (10-50 URLs) and consider caching results for frequently checked domains to reduce API quota consumption.
Expected result: GET /da?url=example.com returns Moz domain authority metrics. POST /da/bulk with a JSON array of URLs returns metrics for all domains in one response.
Python Implementation
Python Implementation
For Python Replit projects, the requests library with HTTP Basic Auth handles Moz API calls cleanly. Flask provides the server layer. Install: pip install requests flask
1# app.py β Moz Links API server in Python2import os3import base644import requests5from flask import Flask, request, jsonify67app = Flask(__name__)89MOZ_API = 'https://api.moz.com/jsonrpc'1011def get_auth_header():12 access_id = os.environ.get('MOZ_ACCESS_ID')13 secret_key = os.environ.get('MOZ_SECRET_KEY')14 if not access_id or not secret_key:15 raise ValueError('MOZ_ACCESS_ID or MOZ_SECRET_KEY not set')16 encoded = base64.b64encode(f'{access_id}:{secret_key}'.encode()).decode()17 return {'Authorization': f'Basic {encoded}', 'Content-Type': 'application/json'}1819def fetch_metrics(url):20 payload = {21 'jsonrpc': '2.0',22 'id': '1',23 'method': 'data.site.metrics.fetch',24 'params': {'data': {'site': url}, 'limit': 1}25 }26 resp = requests.post(MOZ_API, headers=get_auth_header(), json=payload, timeout=15)27 resp.raise_for_status()28 data = resp.json()29 if 'error' in data:30 raise ValueError(f"Moz API error: {data['error']}")31 return data.get('result', {})3233@app.route('/da')34def da():35 url = request.args.get('url')36 if not url:37 return jsonify({'error': 'url parameter required'}), 40038 try:39 metrics = fetch_metrics(url)40 return jsonify({'url': url, 'metrics': metrics})41 except Exception as e:42 return jsonify({'error': str(e)}), 5004344if __name__ == '__main__':45 app.run(host='0.0.0.0', port=3000)Pro tip: Add a simple in-memory cache dict in Python to store recent DA results keyed by URL. For most SEO tools, DA data from 1-24 hours ago is current enough and caching avoids redundant API calls.
Expected result: Running python app.py starts a Flask server. GET /da?url=example.com returns Moz domain authority metrics for the specified URL.
Common use cases
Bulk Domain Authority Checker
Build a Replit API endpoint that accepts a comma-separated list of domains, queries the Moz Links API for each one's Domain Authority, Page Authority, and spam score, and returns a sorted table. Use this to quickly evaluate a list of link building prospects.
Build a Node.js Express server with a POST /bulk-da endpoint that accepts a JSON array of domains, queries Moz Links API v2 for each domain's DA and spam score, and returns an array of results sorted by DA descending. Store MOZ_ACCESS_ID and MOZ_SECRET_KEY in environment variables.
Copy this prompt to try it in Replit
Link Prospect Filter
Create a tool that reads a CSV file of potential backlink targets, checks each domain's Domain Authority using the Moz API, and outputs a filtered CSV containing only domains above a minimum DA threshold. This automates the first step of link building outreach.
Write a Python script that reads a list of domains from a domains.txt file, queries the Moz API for each domain's DA, and writes domains with DA >= 30 to prospects.csv with their DA score included. Store MOZ credentials in environment variables.
Copy this prompt to try it in Replit
SEO Reporting Tool with DA Tracking
Build a server that checks and stores the Domain Authority for a set of tracked domains on a schedule. Each run saves a timestamped snapshot. Over time, this builds a trend line showing how DA changes after link building campaigns or content updates.
Create a Node.js script that checks the DA for each domain in a TRACKED_DOMAINS environment variable (comma-separated), appends the results with a timestamp to a JSON log file, and prints a summary. Design it to run as a Replit Scheduled deployment weekly.
Copy this prompt to try it in Replit
Troubleshooting
HTTP 401 Unauthorized when calling the Moz API
Cause: The Basic Auth header is malformed, the credentials are wrong, or MOZ_ACCESS_ID/MOZ_SECRET_KEY are not set in Replit Secrets.
Solution: Open Replit Secrets and verify both MOZ_ACCESS_ID and MOZ_SECRET_KEY are set. Test the base64 encoding manually: Buffer.from('your-access-id:your-secret-key').toString('base64') in Node.js. Confirm the auth header is 'Basic {base64value}'.
1// Validate credentials are loaded2const accessId = process.env.MOZ_ACCESS_ID || '';3const secretKey = process.env.MOZ_SECRET_KEY || '';4console.log('Access ID loaded:', accessId.startsWith('mozscape-'));5console.log('Secret Key loaded:', secretKey.length > 20);HTTP 403 Forbidden β API access denied
Cause: Your Moz subscription plan does not include API access, or you have exceeded your monthly query limit.
Solution: Log into moz.com β account settings β subscription to verify your plan includes API access. Check your usage at moz.com/products/api/usage. If you have exceeded your quota, you will need to wait for the next billing cycle or upgrade your plan.
API returns metrics of 0 for a domain with known high DA
Cause: The URL format may be wrong β the Moz API expects bare domain format ('example.com') not a full URL with protocol.
Solution: Strip the protocol and trailing slashes from the URL before passing it to the Moz API. Use 'example.com' not 'https://www.example.com/'.
1function cleanUrl(url) {2 return url.replace(/^https?:\/\//, '').replace(/\/+$/, '').split('/')[0];3}JSON-RPC error response β method not found or invalid params
Cause: The method name or params structure in the JSON-RPC request body does not match the Moz API v2 specification.
Solution: Check the Moz API v2 documentation (moz.com/help/links-api) for the exact method names and params structure available to your plan. The v2 API method names differ significantly from the older v1 API.
Best practices
- Store MOZ_ACCESS_ID and MOZ_SECRET_KEY in Replit Secrets β never hardcode them in source files or configuration files
- Cache DA/PA results for 24 hours since Moz updates their index weekly β fresh results are not needed for every request
- Use bulk requests (multiple URLs in one API call) to minimize query quota consumption when checking many domains
- Clean URL inputs by stripping protocols and trailing slashes before calling the Moz API to get consistent results
- Monitor your monthly API query usage in the Moz dashboard to avoid unexpected quota exhaustion mid-project
- Deploy as an Autoscale Replit deployment β DA lookup tools receive sporadic traffic and benefit from scale-to-zero pricing
- Add error handling that gracefully returns partial results when some URLs in a bulk request fail, rather than failing the entire batch
Alternatives
Ahrefs provides a larger backlink index and more comprehensive link analysis than Moz, making it the better choice if your primary need is backlink data rather than Domain Authority metrics.
SEMrush offers a broader marketing API covering keywords, PPC, and content in addition to domain metrics, making it better if you need multiple data types from a single API subscription.
Serpstat provides domain authority and keyword data at a lower price point than Moz, making it worth considering if cost is a primary factor.
Frequently asked questions
How do I connect Replit to the Moz API?
Get your Access ID and Secret Key from moz.com/products/api/keys, store them in Replit Secrets (lock icon π in sidebar), then make HTTP POST requests to https://api.moz.com/jsonrpc with Basic Auth from your server-side Node.js or Python code. The credentials are base64-encoded as 'accessId:secretKey' and passed in the Authorization header.
Does Replit work with the Moz Links API?
Yes. The Moz Links API v2 uses standard HTTPS POST requests with HTTP Basic Authentication, which works from any Replit Node.js or Python backend. Store credentials in Replit Secrets and call the API from your server-side code β never from browser JavaScript.
How do I store my Moz Secret Key in Replit?
Click the lock icon (π) in the Replit sidebar to open the Secrets panel. Add MOZ_ACCESS_ID and MOZ_SECRET_KEY as separate secrets. Access them in Node.js as process.env.MOZ_ACCESS_ID or in Python as os.environ['MOZ_ACCESS_ID']. The values are encrypted and never visible in your code files.
Can I use the Moz API for free on Replit?
No. The Moz Links API requires a paid Moz subscription that includes API access (typically the Medium plan or higher). The free Moz account does not include API access. Moz does offer a free Domain Authority checker tool on their website for manual lookups.
How many Moz API calls can I make per month from Replit?
Your monthly API call limit depends on your Moz subscription plan. Check your current quota and usage at moz.com/products/api/usage. Use bulk requests (multiple URLs in one call) and cache results to maximize the value of your quota.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation