Node.js
DocsNode.js

Node.js

Utilisez RaxyProxy depuis Node.js avec node-fetch, axios ou got.

node-fetch

npm install node-fetch https-proxy-agent

fetch.mjs
import fetch from 'node-fetch';
import { HttpsProxyAgent } from 'https-proxy-agent';

const agent = new HttpsProxyAgent('http://USERNAME:PASSWORD@proxy.raxyproxy.com:823');

const res  = await fetch('https://httpbin.org/ip', { agent });
const data = await res.json();
console.log(data.origin); // proxy IP

axios

npm install axiosle support proxy est intégré.

axios.mjs
import axios from 'axios';

const client = axios.create({
    proxy: {
        protocol: 'http',
        host:     'proxy.raxyproxy.com',
        port:     823,
        auth: { username: 'USERNAME', password: 'PASSWORD' },
    },
    timeout: 15_000,
});

const { data } = await client.get('https://httpbin.org/ip');
console.log(data.origin);
axios-geo.mjs
import axios from 'axios';

// US city-level targeting
const client = axios.create({
    proxy: {
        protocol: 'http',
        host:     'proxy.raxyproxy.com',
        port:     823,
        auth: { username: 'USERNAME__cr.us;city.newyork', password: 'PASSWORD' },
    },
});

const { data } = await client.get('https://httpbin.org/ip');
console.log(data.origin);

got

npm install got hpagent

got.mjs
import got from 'got';
import { HttpProxyAgent } from 'hpagent';

const agent = { https: new HttpProxyAgent({ proxy: 'http://USERNAME:PASSWORD@proxy.raxyproxy.com:823' }) };

const { body } = await got('https://httpbin.org/ip', { agent, responseType: 'json' });
console.log(body.origin);

undici (intégré à Node, v18+)

Pas d'installation supplémentaire — utilise le undici fetch.

undici.mjs
import { ProxyAgent, fetch } from 'undici';

const dispatcher = new ProxyAgent('http://USERNAME:PASSWORD@proxy.raxyproxy.com:823');

const res  = await fetch('https://httpbin.org/ip', { dispatcher });
const data = await res.json();
console.log(data.origin);

Geo-Targeting

geo.mjs
import fetch from 'node-fetch';
import { HttpsProxyAgent } from 'https-proxy-agent';

// Country only — free
const agentUS  = new HttpsProxyAgent('http://USERNAME__cr.us:PASSWORD@proxy.raxyproxy.com:823');

// City — 2× billing for residential/mobile/datacenter
const agentNY  = new HttpsProxyAgent('http://USERNAME__cr.us;city.newyork:PASSWORD@proxy.raxyproxy.com:823');

// Sticky session — same IP ~30 min
const agentSticky = new HttpsProxyAgent('http://USERNAME__sessid.user-42:PASSWORD@proxy.raxyproxy.com:823');

const r = await fetch('https://httpbin.org/ip', { agent: agentUS });
console.log(await r.json());

Requêtes concurrentes

concurrent.mjs
import fetch from 'node-fetch';
import { HttpsProxyAgent } from 'https-proxy-agent';

const PROXY = 'http://USERNAME:PASSWORD@proxy.raxyproxy.com:823';

async function fetchWithProxy(url) {
    const agent = new HttpsProxyAgent(PROXY);
    const res   = await fetch(url, { agent, timeout: 15_000 });
    return res.json();
}

// 20 concurrent requests — each gets a different rotating IP
const urls    = Array.from({ length: 20 }, (_, i) => `https://httpbin.org/ip`);
const results = await Promise.all(urls.map(fetchWithProxy));

results.forEach((r, i) => console.log(`Request ${i + 1}: ${r.origin}`));

Pour l'intégration avec Puppeteer et Playwright, voir la page Puppeteer & Playwright page.