Keyboard shortcuts

Press ← or β†’ to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

πŸ’» Examples

Simple examples showing how to use Vanadum from different programming languages.

🐍 Python

import requests

# Basic GET request
response = requests.get(
    'http://localhost:8000/',
    headers={
        'X-Url': 'https://httpbin.org/get'
    }
)

print(response.text)

# POST request with data
response = requests.post(
    'http://localhost:8000/',
    headers={
        'X-Url': 'https://httpbin.org/post'
    },
    json={'key': 'value'}
)

print(response.json())

# Using with proxy and different profile
response = requests.get(
    'http://localhost:8000/',
    headers={
        'X-Url': 'https://api.ipify.org?format=json',
        'X-Profile': 'firefox',
        'X-Proxy': 'http://proxy.example.com:8080'
    }
)

print(response.text)

πŸ“˜ TypeScript

// Basic GET request
const response = await fetch('http://localhost:8000/', {
  headers: {
    'X-Url': 'https://httpbin.org/get'
  }
});

const data = await response.text();
console.log(data);

// POST request with data
const postResponse = await fetch('http://localhost:8000/', {
  method: 'POST',
  headers: {
    'X-Url': 'https://httpbin.org/post',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ key: 'value' })
});

const postData = await postResponse.json();
console.log(postData);

// Using axios (alternative)
import axios from 'axios';

const axiosResponse = await axios.get('http://localhost:8000/', {
  headers: {
    'X-Url': 'https://api.ipify.org?format=json'
  }
});

console.log(axiosResponse.data);

πŸ¦€ Rust

use reqwest;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
    // Create client
    let client = reqwest::Client::new();
    
    // Basic GET request
    let response = client
        .get("http://localhost:8000/")
        .header("X-Url", "https://httpbin.org/get")
        .send()
        .await?;
    
    let text = response.text().await?;
    println!("{}", text);
    
    // POST request with JSON
    let mut map = HashMap::new();
    map.insert("key", "value");
    
    let post_response = client
        .post("http://localhost:8000/")
        .header("X-Url", "https://httpbin.org/post")
        .json(&map)
        .send()
        .await?;
    
    let post_text = post_response.text().await?;
    println!("{}", post_text);
    
    Ok(())
}

🐹 Go

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    // Basic GET request
    req, err := http.NewRequest("GET", "http://localhost:8000/", nil)
    if err != nil {
        panic(err)
    }
    
    req.Header.Set("X-Url", "https://httpbin.org/get")
    
    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
    
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
    
    // POST request with JSON
    payload := map[string]string{"key": "value"}
    jsonData, _ := json.Marshal(payload)
    
    postReq, err := http.NewRequest("POST", "http://localhost:8000/", bytes.NewBuffer(jsonData))
    if err != nil {
        panic(err)
    }
    
    postReq.Header.Set("X-Url", "https://httpbin.org/post")
    postReq.Header.Set("Content-Type", "application/json")
    
    postResp, err := client.Do(postReq)
    if err != nil {
        panic(err)
    }
    defer postResp.Body.Close()
    
    postBody, _ := io.ReadAll(postResp.Body)
    fmt.Println(string(postBody))
}

πŸ”‘ Headers Reference

Required Headers

  • X-Url: The target URL you want to fetch

Optional Headers

  • X-Profile: Browser profile to emulate (chrome, safari, edge, firefox, okhttp, custom, http11) - defaults to chrome
  • X-Proxy: Proxy server in various formats - see Working with Proxies for all supported formats
  • X-Timeout: Request timeout in seconds (default: 30)
  • X-Redirect: Maximum number of redirects to follow (default: 10)
  • X-Shuffle: Shuffle request headers (true/false, default: false)

Standard HTTP Headers

All standard HTTP headers (User-Agent, Accept, Cookie, etc.) are passed through to the target server.

πŸ’‘ Tips

  1. Default Profile: If not specified, Vanadum uses Chrome profile by default
  2. Error Handling: Check the response status code - Vanadum returns the target server’s status
  3. Proxy Rotation: Change the X-Proxy header for each request to rotate proxies
  4. Performance: Vanadum adds minimal overhead (~5-10ms) to requests

πŸš€ Advanced Usage

Custom Headers

response = requests.get(
    'http://localhost:8000/',
    headers={
        'X-Url': 'https://example.com/api',
        'Authorization': 'Bearer token123',
        'Custom-Header': 'custom-value'
    }
)

Using Different Profiles

# Safari profile for iOS-like requests
resp1 = requests.get('http://localhost:8000/', headers={
    'X-Url': 'https://example.com',
    'X-Profile': 'safari'
})

# Firefox profile
resp2 = requests.get('http://localhost:8000/', headers={
    'X-Url': 'https://example.com',
    'X-Profile': 'firefox'
})

# Custom profile for special cases
resp3 = requests.get('http://localhost:8000/', headers={
    'X-Url': 'https://example.com',
    'X-Profile': 'custom'
})