> ## Documentation Index
> Fetch the complete documentation index at: https://developers.flameproxies.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js

> Working Node.js code for FlameProxies residential, premium residential, and static proxies. Copy-paste examples using axios with proxy agents.

These examples use [axios](https://axios-http.com/) with [https-proxy-agent](https://www.npmjs.com/package/https-proxy-agent) for HTTP proxies and [socks-proxy-agent](https://www.npmjs.com/package/socks-proxy-agent) for SOCKS5. Replace `USERNAME` and `PASSWORD` with your package credentials from the [dashboard](https://flameproxies.com/dashboard).

Install the packages:

```bash theme={null}
npm install axios https-proxy-agent socks-proxy-agent
```

The examples use ES modules and top-level `await`. Save them as `.mjs` files, or set `"type": "module"` in your `package.json`.

## Residential proxies

### Rotating (new IP every request)

```javascript theme={null}
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";

const agent = new HttpsProxyAgent(
  "http://USERNAME-package-standard-country-us:PASSWORD@proxy.flameproxies.com:8989"
);

const { data } = await axios.get("https://ipinfo.io/json", {
  httpsAgent: agent,
  proxy: false,
  timeout: 30000,
});

console.log(data);
```

Each time you run this, you'll get a different IP. Setting `proxy: false` stops axios from applying its own proxy settings on top of the agent.

### Sticky session (same IP across requests)

```javascript theme={null}
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";

const agent = new HttpsProxyAgent(
  "http://USERNAME-package-standard-country-us-session-node1-time-30:PASSWORD@proxy.flameproxies.com:8989"
);

for (let i = 1; i <= 3; i++) {
  const { data } = await axios.get("https://ipinfo.io/json", {
    httpsAgent: agent,
    proxy: false,
    timeout: 30000,
  });
  console.log(`Request ${i}: ${data.ip} (${data.city}, ${data.country})`);
}
```

All three requests return the same IP. The session holds it for up to 30 minutes.

### Target a specific city

```javascript theme={null}
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";

const agent = new HttpsProxyAgent(
  "http://USERNAME-package-standard-country-us-city-newyorkcity:PASSWORD@proxy.flameproxies.com:8989"
);

const { data } = await axios.get("https://ipinfo.io/json", { httpsAgent: agent, proxy: false });
console.log(data);
```

### Fast mode and sub-pools

```javascript theme={null}
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";

const agent = new HttpsProxyAgent(
  "http://USERNAME-package-standard-country-us-pool-1-mode-fast:PASSWORD@proxy.flameproxies.com:8989"
);

const { data } = await axios.get("https://ipinfo.io/json", { httpsAgent: agent, proxy: false });
console.log(data);
```

## Premium residential proxies

Use `package-premium` instead of `package-standard`. Everything else works the same way.

```javascript theme={null}
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";

const agent = new HttpsProxyAgent(
  "http://USERNAME-package-premium-country-gb-session-c3d4-time-20:PASSWORD@proxy.flameproxies.com:8989"
);

const { data } = await axios.get("https://ipinfo.io/json", { httpsAgent: agent, proxy: false });
console.log(data);
```

## SOCKS5

Connect on port `1080` with `socks-proxy-agent`. The `socks5h` scheme resolves hostnames through the proxy:

```javascript theme={null}
import axios from "axios";
import { SocksProxyAgent } from "socks-proxy-agent";

const agent = new SocksProxyAgent(
  "socks5h://USERNAME-package-standard-country-us:PASSWORD@proxy.flameproxies.com:1080"
);

const { data } = await axios.get("https://ipinfo.io/json", {
  httpAgent: agent,
  httpsAgent: agent,
  proxy: false,
});
console.log(data);
```

## Static residential (ISP) proxies

```javascript theme={null}
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";

const agent = new HttpsProxyAgent(
  "http://USERNAME-203.0.113.10:PASSWORD@203.0.113.10.static.flameproxies.com:1337"
);

const { data } = await axios.get("https://ipinfo.io/json", { httpsAgent: agent, proxy: false });
console.log(data);
```

Replace `203.0.113.10` with your static IP. The dashboard shows the exact line for each IP you own.

ISP Monthly IPs (United States) connect straight to the IP instead, with no `.static.flameproxies.com` hostname:

```javascript theme={null}
const agent = new HttpsProxyAgent("http://USERNAME:PASSWORD@203.0.113.10:PORT");
```

## Multiple concurrent sessions

There are no limits on concurrent connections. Give each parallel session its own session ID:

```javascript theme={null}
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";

const targets = [
  { session: "targeta", country: "us" },
  { session: "targetb", country: "gb" },
  { session: "targetc", country: "de" },
];

const results = await Promise.all(
  targets.map(async ({ session, country }) => {
    const agent = new HttpsProxyAgent(
      `http://USERNAME-package-standard-country-${country}-session-${session}-time-10:PASSWORD@proxy.flameproxies.com:8989`
    );
    const { data } = await axios.get("https://ipinfo.io/json", { httpsAgent: agent, proxy: false });
    return `${session}: ${data.ip} (${data.country})`;
  })
);

results.forEach((line) => console.log(line));
```

## Expected response

All examples return a JSON response from [ipinfo.io](https://ipinfo.io):

```json theme={null}
{
  "ip": "203.0.113.45",
  "city": "Los Angeles",
  "country": "US",
  "timezone": "America/Los_Angeles"
}
```

## Next steps

<CardGroup cols={2}>
  <Card title="Python examples" icon="python" href="/examples/python">
    Working Python code for FlameProxies.
  </Card>

  <Card title="Go examples" icon="golang" href="/examples/go">
    Working Go code for FlameProxies.
  </Card>

  <Card title="Residential proxies" icon="house-signal" href="/proxies/residential">
    Full parameter reference.
  </Card>

  <Card title="Connection debugging" icon="wrench" href="/troubleshooting/connection-debugging">
    What to do when something goes wrong.
  </Card>
</CardGroup>
