Set Proxy from API

  • Created

Setting Proxy from API in Kameleo

We recommend that you read the Getting started with Kameleo Automation article before reading this one.

In this article, we'll demonstrate how to set up a proxy for a Kameleo profile using the Local API Clients. Setting up a proxy allows you to route your browsing traffic through a designated proxy server, which can be useful for various web-scraping or browser automation tasks.

Concept

When creating a new profile via the Kameleo Local API, you can specify a proxy configuration using the setProxy method. This method accepts the proxy type (e.g., 'socks5') and the proxy server details such as host, port, username, and password.

Below are examples of how to set up a proxy using the Local API Clients in different programming languages:

We have a separate article about why you need to use a good residential proxy to have the best protection while you are using Kameleo, and we also have an article if you are not familiar with the proxy providers:

Why is a proxy important? How to change your IP address?
Proxy Integrations

With the built-in proxy manager, you can easily integrate any proxy provider with Kameleo even through the Local API.

  • const createProfileRequest = BuilderForCreateProfile
      .forBaseProfile(chromeBaseProfileList[0].id)
      .setRecommendedDefaults()
      .setProxy(
        'socks5',
        {
          host: '<proxy_host>',
          port: <proxy_port>,
          id: '<username>',
          secret: '<password>',
        },
      )
      .build();
    const profile = await client.createProfile({ body: createProfileRequest });
  • var createProfileRequest = BuilderForCreateProfile
      .ForBaseProfile(baseProfileList[0].Id)
      .SetRecommendedDefaults()
      .SetProxy("socks5", new Server("<proxy_host>", <proxy_port>, "<username>", "<password>"))
      .Build();
    
    var profile = await client.CreateProfileAsync(createProfileRequest);
  • create_profile_request = BuilderForCreateProfile \
      .for_base_profile(base_profiles[0].id) \
      .set_recommended_defaults() \
      .set_proxy('socks5', Server(host='<proxy_host>', port=<proxy_port>, id='<username>', secret='<password>')) \
      .build()
    profile = client.create_profile(body=create_profile_request)

Make sure to replace the placeholders (<proxy_host>, <proxy_port>, <username>, <password>) with the actual values of your proxy server.

For your convenience, this functionality is provided by the Builder for Create Profile in the Local API Clients.

Was this article helpful?

0 out of 0 found this helpful