How to Call Browser API

Complete integration guide for calling your containerized browser API from any programming language or application

API Endpoints

Your browser API is deployed globally on Cloudflare's edge network with container processing:

https://gost-dom-browser-api.speedofmastry.workers.dev/browser

fetchURL

Download and analyze any website's HTML content

{"action": "fetchURL", "url": "https://example.com"}

parseHTML

Extract structure and metadata from HTML content

{"action": "parseHTML", "html": "<div>Hello</div>"}

getElement

Find elements using CSS selectors

{"action": "getElement", "html": "...", "options": {"selector": ".class"}}

Health Check

https://gost-dom-browser-api.speedofmastry.workers.dev/health

Integration Examples

JavaScript / Node.js

// Fetch any website
const response = await fetch(
  'https://gost-dom-browser-api.speedofmastry.workers.dev/browser',
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      action: 'fetchURL',
      url: 'https://example.com'
    })
  }
);

const result = await response.json();
console.log('HTML content:', result.data.html);

Python

import requests

# Call the browser API
response = requests.post(
    'https://gost-dom-browser-api.speedofmastry.workers.dev/browser',
    json={
        'action': 'fetchURL',
        'url': 'https://example.com'
    }
)

data = response.json()
print(f"Success: {data['success']}")
print(f"HTML length: {len(data['data']['html'])}")

C# / .NET

using var client = new HttpClient();

var request = new {
    action = "fetchURL",
    url = "https://example.com"
};

var json = JsonSerializer.Serialize(request);
var content = new StringContent(json, Encoding.UTF8, "application/json");

var response = await client.PostAsync(
    "https://gost-dom-browser-api.speedofmastry.workers.dev/browser",
    content
);

var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);

Java

HttpClient client = HttpClient.newHttpClient();

String json = """
    {
        "action": "fetchURL",
        "url": "https://example.com"
    }
    """;

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://gost-dom-browser-api.speedofmastry.workers.dev/browser"))
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(json))
    .build();

HttpResponse<String> response = client.send(request, 
    HttpResponse.BodyHandlers.ofString());

System.out.println(response.body());

Go

package main

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

func main() {
    requestData := map[string]interface{}{
        "action": "fetchURL",
        "url":    "https://example.com",
    }

    jsonData, _ := json.Marshal(requestData)

    resp, err := http.Post(
        "https://gost-dom-browser-api.speedofmastry.workers.dev/browser",
        "application/json",
        bytes.NewBuffer(jsonData),
    )
    
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer resp.Body.Close()
}

Rust

use reqwest;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();
    
    let request_body = json!({
        "action": "fetchURL",
        "url": "https://example.com"
    });

    let response = client
        .post("https://gost-dom-browser-api.speedofmastry.workers.dev/browser")
        .json(&request_body)
        .send()
        .await?;

    let text = response.text().await?;
    println!("{}", text);
    
    Ok(())
}

PowerShell

# Simple API call
$result = Invoke-RestMethod `
    -Uri "https://gost-dom-browser-api.speedofmastry.workers.dev/browser" `
    -Method POST `
    -ContentType "application/json" `
    -Body '{"action":"fetchURL","url":"https://example.com"}'

Write-Host "Success: $($result.success)"
Write-Host "HTML length: $($result.data.html.Length)"

# Parse HTML example
$parseResult = Invoke-RestMethod `
    -Uri "https://gost-dom-browser-api.speedofmastry.workers.dev/browser" `
    -Method POST `
    -ContentType "application/json" `
    -Body '{"action":"parseHTML","html":"<div>Hello</div>"}'

$parseResult | ConvertTo-Json -Depth 3

cURL / Command Line

# Fetch URL
curl -X POST \
  https://gost-dom-browser-api.speedofmastry.workers.dev/browser \
  -H "Content-Type: application/json" \
  -d '{"action":"fetchURL","url":"https://example.com"}'

# Parse HTML
curl -X POST \
  https://gost-dom-browser-api.speedofmastry.workers.dev/browser \
  -H "Content-Type: application/json" \
  -d '{"action":"parseHTML","html":"<div>Hello</div>"}'

# Find Element
curl -X POST \
  https://gost-dom-browser-api.speedofmastry.workers.dev/browser \
  -H "Content-Type: application/json" \
  -d '{"action":"getElement","html":"<div class=\"test\">Hello</div>","options":{"selector":".test"}}'

Quick Reference

Request Format

{
  "action": "fetchURL|parseHTML|getElement",
  "url": "https://example.com",           // for fetchURL
  "html": "<div>content</div>",          // for parseHTML/getElement  
  "options": {"selector": ".class"}      // for getElement
}

Response Format

{
  "success": true,
  "data": {
    "html": "...",
    "containerProcessed": true,
    "statusCode": 200,
    "headers": {...}
  }
}

Error Response

{
  "success": false,
  "error": "Error message describing what went wrong"
}