Node.js API Example for Meta, DNS, and Screenshot
Using the axios (opens in a new tab) package from NPM, we can call the URL Meta API like this:
const axios = require("axios")
const authKey = "YOUR_AUTH_KEY" // your auth key from dashboard
const targetURL = "https://backupdiary.com"
axios
// to get the DNS records, change the URL to https://api.urlmeta.org/dns?domain=backupdiary.com
// for screenshot, change the URL to https://api.urlmeta.org/screenshot?url=https://backupdiary.com
.get(`https://api.urlmeta.org/meta?url=${encodeURIComponent(targetURL)}`, {
headers: {
Authorization: `Basic ${authKey}`,
},
})
.then((response) => {
const data = response.data
if (data.result.status == "OK") {
console.log(data)
} else {
console.log("URL Meta error:", data.result.reason)
}
})
.catch((err) => console.log(err))
Render image from HTML or SVG
const axios = require("axios")
const authKey = "YOUR_AUTH_KEY" // your auth key from dashboard
const svgString = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"100\" height=\"100\"><rect width=\"300\" height=\"100\" style=\"fill:rgb(0,0,255);stroke-width:1;stroke:rgb(0,0,0)\" /></svg>" // just a blue rectangle
axios({
method: "post",
url: `https://api.urlmeta.org/render?format=svg`,
headers: {
Authorization: `Basic ${authKey}`,
"Content-Type": "application/xml",
},
data: svgString,
})
.then((response) => {
const data = response.data
if (data.result.status == "OK") {
console.log(data)
} else {
console.log("URL Meta error:", data.result.reason)
}
})
.catch((err) => console.log(err))