apex-data-for-seo
Version:
A comprehensive MCP server for DataForSEO API
54 lines • 1.58 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataForSeoClient = void 0;
const axios_1 = __importDefault(require("axios"));
/**
* Client for the DataForSEO API
*/
class DataForSeoClient {
constructor(login, password) {
this.baseUrl = 'https://api.dataforseo.com/v3';
// Create an axios instance with authentication
this.client = axios_1.default.create({
baseURL: this.baseUrl,
auth: {
username: login,
password: password,
},
headers: {
'Content-Type': 'application/json'
}
});
}
/**
* Make a GET request to the DataForSEO API
*/
async get(path) {
try {
const response = await this.client.get(path);
return response.data;
}
catch (error) {
console.error(`Error in GET request to ${path}:`, error);
throw error;
}
}
/**
* Make a POST request to the DataForSEO API
*/
async post(path, data) {
try {
const response = await this.client.post(path, data);
return response.data;
}
catch (error) {
console.error(`Error in POST request to ${path}:`, error);
throw error;
}
}
}
exports.DataForSeoClient = DataForSeoClient;
//# sourceMappingURL=client.js.map