Tutorial

How to Give AI Agents Web Intelligence

Use SnapAPI as a tool in LangChain, OpenAI, or Claude tool calling. Your agent gets structured page understanding — type, CTA, tech stack, and optional snapshot — not just raw HTML.

Steps

  1. Use /v1/analyze as the agent toolPoint your agent at /v1/analyze. It returns page_type, primary_cta (text + href), technologies, forms, nav items, word_count, and OG metadata — structured JSON your LLM can reason about directly.
  2. Add screenshot=true when vision helpsInclude screenshot=true to also receive a base64 image. Pass it to a vision model when the agent needs visual context (layout, branding, dynamic content).
  3. Define the tool schemaRegister SnapAPI as an OpenAI function or LangChain tool with parameters: url (required), screenshot (bool, optional). The structured response needs no parsing — fields map directly to agent reasoning.
  4. Let the agent decide what to do nextThe page_type and primary_cta fields tell the agent what kind of page it's looking at and what action the site wants users to take — ideal for web automation, research, and competitive analysis.

Code Examples

# Get tool definition
curl "https://snapapi.tech/v1/tool"

# Analyze a page (structured intelligence)
curl "https://snapapi.tech/v1/analyze?url=https://example.com" \
  -H "x-api-key: YOUR_KEY" | jq '{page_type, primary_cta, technologies, word_count}'
import requests

def snapapi_analyze(url: str, screenshot: bool = False) -> dict:
    """Analyze a webpage — returns page type, CTA, technologies, and structure."""
    params = {"url": url}
    if screenshot:
        params["screenshot"] = "true"
    response = requests.get(
        "https://snapapi.tech/v1/analyze",
        params=params,
        headers={"x-api-key": "YOUR_KEY"}
    ).json()
    return {
        "page_type": response.get("page_type"),
        "primary_cta": response.get("primary_cta"),
        "technologies": response.get("technologies", []),
        "word_count": response.get("word_count"),
        "screenshot": response.get("screenshot", "")  # base64 if requested
    }

# Use with LangChain, OpenAI function calling, etc.
result = snapapi_analyze("https://stripe.com")
print(result["page_type"])           # "landing"
print(result["primary_cta"]["text"]) # "Start now"
// OpenAI function calling tool definition
const tools = [{
  type: "function",
  function: {
    name: "analyze_webpage",
    description: "Analyze a webpage — returns page type, primary CTA, technologies, word count, and optional visual snapshot",
    parameters: {
      type: "object",
      properties: {
        url: { type: "string", description: "URL to analyze" },
        screenshot: { type: "boolean", description: "Include visual snapshot (base64)" }
      },
      required: ["url"]
    }
  }
}];

// When agent calls the tool
async function analyze_webpage({ url, screenshot = false }) {
  const params = new URLSearchParams({ url });
  if (screenshot) params.set("screenshot", "true");
  const res = await fetch(
    "https://snapapi.tech/v1/analyze?" + params,
    { headers: { "x-api-key": "YOUR_KEY" } }
  );
  return await res.json();
}
Get Free API KeyFull API Docs