import { GoogleAdsApi } from "google-ads-api";
// Replace these example credentials with your real credentials.
const client = new GoogleAdsApi({
client_id: "#",
client_secret: "#",
developer_token: "#",
})
async function checkConnection() {
const customer = client.Customer({
customer_account_id: '#',
refresh_token: '#',
})
try {
// Try to retrieve some campaigns to check the connection.
const campaigns = await customer.report({
entity: 'campaign',
limit: 5, // Modify this number as needed
})
if (campaigns.length === 0) {
console.log('No campaigns created at the moment');
} else {
console.log('API connected successfully');
}
} catch (err) {
console.error('Error connecting to the API', err)
}
}
checkConnection()