Skip to content

API: Getting Started

Ready to make your first request? Let's go.


Prerequisites

Before proceeding, ensure:

  1. Extension is Installed: See guide
  2. Extension is Connected: Popup shows Connected ✓
  3. You have your URL: Copy it from the extension popup.

Important

Your extension can only process one request at a time. Do not send parallel requests to the same WebSocket ID. If you need 10 concurrent requests, you need 10 different browser profiles/extensions running.


The easiest way to verify everything is working is to use our visual playground.

  1. Open the Playground: https://app.aimodeapi.com/playground
  2. Paste your Endpoint: Enter the URL from your extension (e.g., https://app.aimodeapi.com/api/abc...).
  3. Ask a Question: Type "Hello" or "What is AI?".
  4. Send: Click the button and watch your browser process it.

If the Playground works, your API integration will work too.


Option 2: Code Examples

Ready to write code? Here is how to call your API.

Prerequisites

  • Your unique API endpoint: https://app.aimodeapi.com/api/{your-id}
  • A tool to send HTTP POST requests.
test_api.py
import requests

# REPLACE with your actual endpoint from the extension
API_ENDPOINT = "https://app.aimodeapi.com/api/abc123-def456"

print(f"Sending request to {API_ENDPOINT}...")

try:
    response = requests.post(
        API_ENDPOINT,
        json={"query": "What are the benefits of open source?"},
        timeout=70 # Google AI can be slow, give it time
    )

    response.raise_for_status()
    data = response.json()

    # Access the structured data
    answer = data["response"]["response_body"]
    sources = data["response"]["sources"]

    print("\n=== Answer ===\n")
    print(answer[:200] + "...") # Print first 200 chars

    print(f"\nFound {len(sources)} sources.")

except Exception as e:
    print(f"Error: {e}")
test_api.js
// REPLACE with your actual endpoint from the extension
const API_ENDPOINT = "https://app.aimodeapi.com/api/abc123-def456";

async function askAI() {
    console.log(`Sending request to ${API_ENDPOINT}...`);

    try {
        const response = await fetch(API_ENDPOINT, {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({ 
                query: 'What are the benefits of open source?' 
            })
        });

        if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);

        const data = await response.json();

        console.log("\n=== Answer ===\n");
        console.log(data.response.response_body.substring(0, 200) + "...");

        console.log(`\nFound ${data.response.sources.length} sources.`);

    } catch (error) {
        console.error("Error:", error);
    }
}

askAI();
test_api.sh
curl -X POST https://app.aimodeapi.com/api/YOUR_ID_HERE \
  -H "Content-Type: application/json" \
  -d '{"query": "What are the benefits of open source?"}'

Understanding the Response

You will receive a JSON object with this structure:

{
  "response": {
    "success": true,
    "processed_at": "2023-10-27T10:00:00.000Z",
    "data": {
      "response_body": "Open source software provides...",
      "sources": [
        {
          "url": "https://opensource.org/...",
          "title": "Open Source Initiative",
          "description": "The benefits of open source...",
          "source": "opensource.org"
        }
      ],
      "follow_up_questions": [
          "What are open source licenses?",
          "History of open source"
      ]
    }
  }
}
  • success: Boolean indicating if the extension successfully processed the query.
  • data.response_body: The main answer, formatted in Markdown.
  • data.sources: A list of citations Google provided.
  • data.follow_up_questions: Suggested questions for deeper research.

What Just Happened?

  1. You sent a JSON payload with your question.
  2. Our server routed it to your browser extension via WebSocket.
  3. Your browser opened a background tab to Google AI Mode.
  4. Google generated the answer, and your extension scraped it.
  5. The structured data was returned to your script.

Next Steps