Set Geolocation from API

  • Created

In this article, we'll guide you through setting up Geolocation spoofing in Kameleo whilst using the Local API Clients. Geolocation spoofing allows you to modify the location information of your virtual browser profile to simulate different geographical locations for web-scraping or browser automation projects.

We also encourage you to learn more about Geolocation spoofing from our article: Geolocation API

Concept

During the CreateProfileRequest

POST /profiles/new

You can pass the CreateProfileRequest object that has a GeolocationSpoofingType property. This can be used to set up Geolocation spoofing. Furthermore, when creating a new profile via the Kameleo Local API, you can specify Geolocation spoofing behavior using the setGeolocation method. Possible values for the Geolocation spoofing type are:

  • Automatic: Automatically set the geolocation values based on the IP address.
  • Manual: Manually set the longitude and latitude in the profile. When using this option, you must provide the geolocation coordinates.
  • Block: Completely block the Geolocation API.
  • Off: Turn off the spoofing and use the original settings.

We suggest you to use the automatic settings that are included in the set recommended defaults call.

To set the Geolocation spoofing type, use the setGeolocation method in the Local API Clients. Below are examples in Javascript and Python:

Examples

  • const createProfileRequest = BuilderForCreateProfile
        .forBaseProfile(baseProfileId)
        .setGeolocation({
            value: 'manual',
            extra: {
                latitude: 59.43984,
                longitude: 24.75815
            }
        })
        .build();
    const profile = await client.createProfile({ body: createProfileRequest });
  • create_profile_request = BuilderForCreateProfile \
        .for_base_profile(base_profiles[0].id) \
        .setGeolocation({
            'value': 'manual',
            'extra': {
                'latitude': 59.43984,
                'longitude': 24.75815
            }
        }) \
        .build()
    profile = client.create_profile(body=create_profile_request)

Use the appropriate Geolocation spoofing type according to your needs for web automation or scraping tasks.

For your convenience, this functionality is provided by the Python Builder and JavaScript Builder for Profile Creation in the Local API Clients.

Was this article helpful?

0 out of 0 found this helpful