# Code examples

Source: https://ipvolt.com/docs/code-examples
Markdown: https://ipvolt.com/docs/code-examples.md

[Home](https://ipvolt.com/index.md) / [Docs](https://ipvolt.com/docs.md) / [Code examples](https://ipvolt.com/docs/code-examples.md)

Section: Build
Updated: 2026-11-05
Author: ipvolt

Copy-ready examples for an ipvolt mobile proxy in cURL, Python Requests, HTTPX, aiohttp, Node.js, Playwright, Puppeteer, Scrapy and Go.

Each example sends one request through an ipvolt mobile proxy and prints the outgoing IP. They read the connection details from environment variables, so no credentials end up in your code:

```sh
export PROXY_URL="http://USERNAME:PASSWORD@HOST:HTTP_PORT"
export PROXY_HOST="HOST"
export PROXY_HTTP_PORT="HTTP_PORT"
export PROXY_USERNAME="USERNAME"
export PROXY_PASSWORD="PASSWORD"
```

The printed IP should match the outgoing IP in your dashboard. Each section links to a guide that covers the client's options and errors in depth.

## cURL

```sh
curl -sS -x "$PROXY_URL" https://api.ipify.org
```

For SOCKS5, use `-x "socks5h://USERNAME:PASSWORD@HOST:SOCKS5_PORT"`. See [Use a proxy with curl](/guides/curl-proxy-setup).

## Python Requests

```python
import os
import requests

proxy = os.environ["PROXY_URL"]
response = requests.get("https://api.ipify.org", proxies={"http": proxy, "https": proxy}, timeout=30)
print(response.text)
```

For a `socks5h://` URL, install `requests[socks]` first. See [Python Requests proxy](/guides/python-requests-proxy).

## Python HTTPX

```python
import os
import httpx

with httpx.Client(proxy=os.environ["PROXY_URL"], timeout=30) as client:
    print(client.get("https://api.ipify.org").text)
```

See [HTTPX async proxies](/guides/httpx-async-proxy).

## Python aiohttp

```python
import asyncio
import os
import aiohttp


async def main():
    async with aiohttp.ClientSession() as session:
        async with session.get("https://api.ipify.org", proxy=os.environ["PROXY_URL"]) as response:
            print(await response.text())


asyncio.run(main())
```

See [aiohttp proxies](/guides/aiohttp-proxy-setup).

## Node.js

```js
import { fetch, ProxyAgent } from 'undici';

const dispatcher = new ProxyAgent(process.env.PROXY_URL);
const response = await fetch('https://api.ipify.org', { dispatcher });
console.log(await response.text());
```

On Node.js 24.5 or later, the built-in `fetch` can use the proxy without undici: run your script with `NODE_USE_ENV_PROXY=1` and `HTTPS_PROXY` set to the proxy URL. See [Use a proxy with Node.js fetch](/guides/nodejs-fetch-proxy).

## Playwright

```js
import { chromium } from 'playwright';

const browser = await chromium.launch({
  proxy: {
    server: `http://${process.env.PROXY_HOST}:${process.env.PROXY_HTTP_PORT}`,
    username: process.env.PROXY_USERNAME,
    password: process.env.PROXY_PASSWORD,
  },
});
const page = await browser.newPage();
await page.goto('https://api.ipify.org');
console.log(await page.textContent('body'));
await browser.close();
```

Use the HTTP port for browsers: Chromium does not send SOCKS5 credentials. See [Configure a proxy in Playwright](/guides/playwright-proxy-setup).

## Puppeteer

```js
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({
  args: [`--proxy-server=http://${process.env.PROXY_HOST}:${process.env.PROXY_HTTP_PORT}`],
});
const page = await browser.newPage();
await page.authenticate({ username: process.env.PROXY_USERNAME, password: process.env.PROXY_PASSWORD });
await page.goto('https://api.ipify.org');
console.log(await page.evaluate(() => document.body.innerText));
await browser.close();
```

See [Fix ERR_TUNNEL_CONNECTION_FAILED](/guides/fix-err-tunnel-connection-failed) if the page does not load.

## Scrapy

```python
import os
import scrapy


class IpSpider(scrapy.Spider):
    name = "ip"

    async def start(self):
        yield scrapy.Request("https://api.ipify.org", meta={"proxy": os.environ["PROXY_URL"]})

    def parse(self, response):
        self.logger.info("Outgoing IP: %s", response.text)
```

See [Scrapy proxies](/guides/scrapy-proxy-setup).

## Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"net/url"
	"os"
	"time"
)

func main() {
	proxyURL, err := url.Parse(os.Getenv("PROXY_URL"))
	if err != nil {
		panic(err)
	}
	client := &http.Client{
		Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
		Timeout:   30 * time.Second,
	}
	resp, err := client.Get("https://api.ipify.org")
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	body, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(body))
}
```

## More documentation

- Previous: [Locations and carriers](https://ipvolt.com/docs/locations.md)
- Next: [Integrations](https://ipvolt.com/docs/integrations.md)
- [All documentation](https://ipvolt.com/docs.md)
