constaxios=require("axios");const { writeFileSync } =require('fs');axios.get('https://api.night-api.com/images/captcha', { headers: { authorization:"Your API token" }, data: { codeSize:9// Between 4 and 10 }}).then(asyncfunction (res) {console.log(res.data);writeFileSync(`${__dirname}/captcha.png`,Buffer.from(res.data.content.image,'base64'));})
Or with the module
// Return: Promiseconst { NightAPI } =require('night-api');constapi=newNightAPI('YOUR_API_KEY');constcaptha=awaitapi.captcha.generate(); // Generate captcha// You can use this function for choose the number of caracters beetween 4 and 10constcaptha=awaitapi.captcha.generate(6);