Skip to content

Proxy Configuration

Configure proxies for web scraping operations.

Why Use a Proxy?

Proxies are recommended for web scraping to:

  • Avoid IP blocks
  • Distribute requests
  • Enable geo-targeting
  • Improve reliability

Supported Providers

  • Oxylabs (recommended)
  • BrightData
  • Custom (any HTTP/HTTPS proxy)

Configuration

Oxylabs

typescript
const client = new XTwitterClient({
  proxy: {
    enabled: true,
    provider: 'oxylabs',
    username: process.env.PROXY_USERNAME,
    password: process.env.PROXY_PASSWORD,
    country: 'us'
  }
});

BrightData

typescript
const client = new XTwitterClient({
  proxy: {
    enabled: true,
    provider: 'brightdata',
    username: process.env.PROXY_USERNAME,
    password: process.env.PROXY_PASSWORD,
    country: 'us'
  }
});

Custom Proxy

typescript
const client = new XTwitterClient({
  proxy: {
    enabled: true,
    provider: 'custom',
    host: 'proxy.example.com',
    port: 8080,
    username: 'user',
    password: 'pass'
  }
});

Per-Account Proxy

Configure different proxies per account:

typescript
const client = new XTwitterClient({
  crawler: {
    accounts: [
      {
        id: 'account1',
        username: '@user1',
        cookies: {...},
        country: 'us' // US proxy for this account
      },
      {
        id: 'account2',
        username: '@user2',
        cookies: {...},
        country: 'uk' // UK proxy for this account
      }
    ]
  },
  proxy: {
    enabled: true,
    provider: 'oxylabs',
    username: '...',
    password: '...'
  }
});

Next Steps

Released under the MIT License.