Proxies

Route browser traffic through proxies to change IP addresses. You can:

  • Use Hyperbrowser's proxy pool

  • Bring your own proxies

To enable these proxy configurations, you can set them in the session creation params.

import { connect } from "puppeteer-core";
import { Hyperbrowser } from "@hyperbrowser/sdk";
import { config } from "dotenv";

config();

const client = new Hyperbrowser({
  apiKey: process.env.HYPERBROWSER_API_KEY,
});

const main = async () => {
  const session = await client.sessions.create({
    useProxy: true,
    proxyCountry: "US",
    // use own proxy
    /**
     * proxyServer: "http://...",
     * proxyServerUsername: "...",
     * proxyServerPassword: "...",
     */
  });

  try {
    const browser = await connect({
      browserWSEndpoint: session.wsEndpoint,
      defaultViewport: null,
    });

    const [page] = await browser.pages();

    // Navigate to a website
    console.log("Navigating to Hacker News...");
    await page.goto("https://news.ycombinator.com/");
    const pageTitle = await page.title();
    console.log("Page 1:", pageTitle);
    await page.evaluate(() => {
      console.log("Page 1:", document.title);
    });
  } catch (err) {
    console.error(`Encountered error: ${err}`);
  } finally {
    await client.sessions.stop(session.id);
  }
};

main();

Using proxies can introduce latency to any page navigations, so make sure to properly await these navigations with timeouts.

Proxy usage requires being on a PAID plan.

Geospecific Proxies

Hyperbrowser supports geo-specific IPs as well. The specificity can range from country level down to city level. This can be specified by

...
await client.sessions.create({
    useProxy: true,
    proxyCountry: "US",
    // or proxyCity: "New York"
  });
...

While Hyperbrowser supports nearly all countries and most cities, not all areas are guaranteed to be available. Especially for areas with low population density, separate testing should be done to ensure that adequate coverage is available.

Custom Proxies

If you want to use your own proxy service/providers, you can do so by specifying the following parameters when creating a session. If you use your own proxy provider, you will not be billed for any proxy usage.

When setting the proxyServer, ensure that you start it with the scheme like http:// for example.

...
await client.sessions.create({
    useProxy: true,
    proxyServer: "scheme://subdomain.proxyprovider.io:10000",
    proxyServerUsername: "proxy-username",
    proxyServerPassword: "proxy-password",
  });
...

Proxy usage is only available on the PAID plans.

Last updated