Kameleo.LocalApiClient
3.4.0
dotnet add package Kameleo.LocalApiClient --version 3.4.0
NuGet\Install-Package Kameleo.LocalApiClient -Version 3.4.0
<PackageReference Include="Kameleo.LocalApiClient" Version="3.4.0" />
paket add Kameleo.LocalApiClient --version 3.4.0
#r "nuget: Kameleo.LocalApiClient, 3.4.0"
// Install Kameleo.LocalApiClient as a Cake Addin #addin nuget:?package=Kameleo.LocalApiClient&version=3.4.0 // Install Kameleo.LocalApiClient as a Cake Tool #tool nuget:?package=Kameleo.LocalApiClient&version=3.4.0
Kameleo Local API Client
With Kameleo, you can easily create multiple virtual browser profiles to work with multiple accounts. It helps you hide your actual timezone, geolocation, language, IP address and creates natural browser fingerprints to prevent detection by anti-bot systems. Kameleo is compatible with Selenium, Playwright, and Puppeteer frameworks for automating web scraping tasks. This .NET Standard package provides convenient access to the Local API REST interface of the Kameleo Client. See the article in our knowledge base for Getting Started with Kameleo Automation.
Features
- Stay completely undetected, so websites won't be able to detect that you are using automation tools
- Start unlimited number of profiles with different natural browser fingerprints
- Use authenticated HTTP/SOCKS/SSH proxies in browsers
- Create isolated browsing environments simultaneously
- Use real browser profiles of Chrome, Firefox, Safari and Edge
- Edit, Import or Export browser cookies
- Modify WebRTC parameters
- Modify Geolocation settings
- Modify Timezone and Language settings
- Modify WebGL fingerprint
- Modify 2D Canvas fingerprint
- Modify Navigator properties
- Modify Screen resolution
Note: You need Automation package of Kameleo to access the features described below.
Quickstart Guide
1. Install by NuGet
Install-Package Kameleo.LocalApiClient
2. Start the Kameleo.CLI on your computer
./Kameleo.CLI email="your@email.com" password="Pa$$w0rd"
3. Start a browser with out-of-the-box fingerprinting protection
using System;
using Kameleo.LocalApiClient;
const string KameleoBaseUrl = "http://localhost:5050";
var client = new KameleoLocalApiClient(new Uri(KameleoBaseUrl));
client.SetRetryPolicy(null);
// Search Chrome Base Profiles
var baseProfiles = await client.SearchBaseProfilesAsync(
deviceType: "desktop",
browserProduct: "chrome");
// Create a new profile with recommended settings
// for browser fingerprint protection
var requestBody = BuilderForCreateProfile
.ForBaseProfile(baseProfiles[0].Id)
.SetName("example profile")
.SetRecommendedDefaults()
.Build();
var profile = await client.CreateProfileAsync(requestBody);
// Start the browser
await client.StartProfileAsync(profile.Id);
// At this point you can automate the browser with your favorite framework
Automate Kameleo profiles with Selenium
Kameleo gives you the ability to control any supported browser using Selenium. It uses the WebDriver protocol, a W3C specification, and industry-standard to interact with a browser.
You need to install the official Selenium package.
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Remote;
const int KameleoPort = 5050;
// Connect to the running browser instance using WebDriver
var uri = new Uri($"http://localhost:{KameleoPort}/webdriver");
var opts = new ChromeOptions();
opts.AddAdditionalOption("kameleo:profileId", profile.Id.ToString());
var webdriver = new RemoteWebDriver(uri, opts);
// Use any WebDriver command to drive the browser
// and enjoy full protection from bot detection products
webdriver.Navigate().GoToUrl("https://google.com");
The full example can be found here.
Automate Kameleo profiles with Puppeteer (Chromium-based)
Kameleo lets you control Chromium-based browsers (sorry Firefox fans) using the Puppeteer.Sharp package. In this simple example you can see how to connect to the browser that Kameleo starts.
You need to import the Puppeteer.Sharp.
using PuppeteerSharp;
// Connect to the browser through CDP
const int KameleoPort = 5050;
var browserWsEndpoint = $"ws://localhost:{KameleoPort}/puppeteer/{profile.Id}";
var browser = await Puppeteer.ConnectAsync(new ConnectOptions {
BrowserWSEndpoint = browserWsEndpoint,
DefaultViewport = null });
var page = await browser.NewPageAsync();
// Use any Puppeteer command to drive the browser
// and enjoy full protection from bot detection products
await page.GoToAsync("https://google.com");
The full example can be found here.
Automate Kameleo profiles with Playwright
Kameleo allows you to control the browser with the official Playwright package. It works little bit different with Chromium-based browsers and Firefox, so we provide an example for both. Here we showcase how you can connect to the browser that is already started by Kameleo.
You need to import the official Playwright package.
using Microsoft.Playwright;
You can find more details here: Using Kameleo with Playwright framework – Kameleo Support Center.
Chromium-based profiles with Playwright
// Connect to the browser with Playwright through CDP
const int KameleoPort = 5050;
var browserWsEndpoint = $"ws://localhost:{KameleoPort}/playwright/{profile.Id}";
var playwright = await Playwright.CreateAsync();
var browser = await playwright.Chromium.ConnectOverCDPAsync(browserWsEndpoint);
// It is recommended to work on the default context.
// NOTE: We DO NOT recommend using multiple browser contexts, as this might interfere
// with Kameleo's browser fingerprint modification features.
var context = browser.Contexts[0];
var page = await context.NewPageAsync();
// Use any Playwright command to drive the browser
// and enjoy full protection from bot detection products
await page.GotoAsync("https://google.com");
The full example can be found here.
Firefox-based profiles with Playwright
// Connect to the browser with Playwright
const int KameleoPort = 5050;
var browserWsEndpoint = $"ws://localhost:{KameleoPort}/playwright/{profile.Id}";
// The Playwright framework is not designed to connect to already running
// browsers. To overcome this limitation, a tool bundled with Kameleo, named
// pw-bridge will bridge the communication gap between the running Firefox
// instance and this playwright script.
// The exact path to the bridge executable is subject to change.
var pwBridgePath = Environment.GetEnvironmentVariable("PW_BRIDGE_PATH");
if (pwBridgePath is null && OperatingSystem.IsWindows())
{
var localAppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
pwBridgePath = Path.Combine(localAppDataFolder, "Programs", "Kameleo", "pw-bridge.exe");
}
else if (pwBridgePath is null && OperatingSystem.IsMacOS())
{
pwBridgePath = "/Applications/Kameleo.app/Contents/MacOS/pw-bridge";
}
var playwright = await Playwright.CreateAsync();
var browser = await playwright.Firefox.LaunchPersistentContextAsync("", new BrowserTypeLaunchPersistentContextOptions
{
ExecutablePath = pwBridgePath,
Args = new List<string> { $"-target {browserWsEndpoint}" },
ViewportSize = null,
});
// Kameleo will open the a new page in the default browser context.
// NOTE: We DO NOT recommend using multiple browser contexts, as this might interfere
// with Kameleo's browser fingerprint modification features.
var page = await browser.NewPageAsync();
// Use any Playwright command to drive the browser
// and enjoy full protection from bot detection products
await page.GotoAsync("https://google.com");
The full example can be found here.
Automate mobile profiles
Kameleo can emulate mobile devices in the custom built Chromium.
var baseProfileList = await client.SearchBaseProfilesAsync(
"mobile",
"ios",
"safari",
"en-us");
// Create a new profile with recommended settings
// Choose one of the Base Profiles
// Set the launcher to 'chromium' so the mobile profile will be started in Chroma browser
var createProfileRequest = BuilderForCreateProfile
.ForBaseProfile(baseProfileList[0].Id)
.SetName("automate mobile profiles on desktop example")
.SetRecommendedDefaults()
.SetLauncher("chromium")
.Build();
var profile = await client.CreateProfileAsync(createProfileRequest);
// Start the profile with a couple of extra parameters, so Selenium automation can be done fluently
await client.StartProfileWithOptionsAsync(profile.Id, new WebDriverSettings()
{
AdditionalOptions = new List<Preference>
{
// This allows you to click on elements using the cursor when emulating a touch screen in the brower.
// If you leave this out, your script may time out after clicks and fail.
new Preference("disableTouchEmulation", true),
}
});
// At this point you can automate the browser with your favorite framework
The full example can be found here.
Example codes
Several examples have been prepared in a different repository to showcase the most interesting features. Feel free to create a pull request to add new example codes.
- Finding base profiles
- Creating profiles with custom options
- Updating profiles with new settings
- How to start a profile
- Using Selenium with Local API
- Using Playwright with Kameleo
- Using Puppeteer with Kameleo
- How to emulate mobile devices
- Adding an HTTP, SOCKS or SSH proxy to profile
- Saving/Loading a browsing session to/from a .kameleo file
- Modify and Delete browser cookies
- Start profile with extra WebDriver capabilities
- How to duplicate virtual browser profiles
- Refresh the browser of the emulated profiles
Note: If you are interested in more information about Kameleo, or have encountered an issue with using it, please check out our Help Center.
Package
This package can be found on NuGet Gallery here: Kameleo.LocalApiClient.
License
This project is released under MIT License. Please refer the LICENSE.txt for more details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Rest.ClientRuntime (>= 2.3.24)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.4.0 | 75 | 11/13/2024 |
3.2.0 | 169 | 5/13/2024 |
3.1.1 | 215 | 3/20/2024 |
3.1.0 | 339 | 2/7/2024 |
3.0.0 | 429 | 7/21/2023 |
2.11.0 | 478 | 2/8/2023 |
2.10.0 | 493 | 11/15/2022 |
2.9.0 | 535 | 8/18/2022 |
2.6.0 | 14,648 | 2/18/2022 |
2.3.2 | 553 | 7/21/2021 |
2.3.1 | 453 | 7/21/2021 |
2.3.0 | 462 | 7/21/2021 |
2.0.2 | 577 | 12/21/2020 |
2.0.1 | 536 | 12/21/2020 |
2.0.0 | 591 | 12/7/2020 |