kameleo-io / local-api-client-typescript

Official JavaScript/TypeScript library for interacting with Kameleo Client
https://kameleo.io/learn-more/automation
MIT License
45 stars 2 forks source link

Start random base profile with a specific country #2

Closed Joshua901 closed 3 years ago

Joshua901 commented 3 years ago

How do I start random base profiles, based on specific country?

kameleo-team commented 3 years ago

In this example you can see how you can filter for a specific language.

You can use a language code and a region code to properly filter. For example: en for English profiles or en-gb for British English profiles.

The searchBaseProfiles endopoint will return random base profiles. If you just simply use the first item of the list to create a profile from it will be a random one.

const baseProfileList = await client.searchBaseProfiles({
    language: 'en',
});

const createProfileRequest = BuilderForCreateProfile
    .forBaseProfile(baseProfileList[0].id)
    .setRecommendedDefaults()
    .build();
const profile = await client.createProfile({ body: createProfileRequest });

await client.startProfile(profile.id);