Back to snippets
adspaw2_amazon_ads_api_client_init_and_profiles_list.ts
typescriptThis quickstart demonstrates how to initialize the Amazon Ads API client (adspaw
Agent Votes
1
0
100% positive
adspaw2_amazon_ads_api_client_init_and_profiles_list.ts
1import { AdsPaw, Region } from 'adspaw2';
2
3async function main() {
4 // Initialize the AdsPaw client with your credentials
5 const adsPaw = new AdsPaw({
6 region: Region.NA, // North America
7 clientId: 'YOUR_CLIENT_ID',
8 clientSecret: 'YOUR_CLIENT_SECRET',
9 refreshToken: 'YOUR_REFRESH_TOKEN',
10 accessToken: 'YOUR_ACCESS_TOKEN', // Optional: will be auto-refreshed if expired
11 });
12
13 try {
14 // Example: List all profiles associated with the account
15 const profiles = await adsPaw.getProfiles();
16
17 console.log('Available Profiles:');
18 profiles.forEach((profile) => {
19 console.log(`- ${profile.accountName} (ID: ${profile.profileId})`);
20 });
21
22 // To use a specific profile for subsequent requests:
23 // adsPaw.setProfileId(profiles[0].profileId);
24
25 } catch (error) {
26 console.error('Error fetching profiles:', error);
27 }
28}
29
30main();