@cloro-dev/cloro npm package is the official TypeScript/Node SDK for the cloro API — one typed client for Google Search and every AI answer engine. Each call is a single authenticated request that returns structured JSON with sources; there are no proxies, headless browsers, or selectors to maintain. It ships ESM and CommonJS builds with bundled type declarations. The source lives in the cloro-node repository.
This page is the SDK reference. For a guided walkthrough with recipes, cost math, and production patterns, see the JavaScript & Node API guide. Prefer raw HTTP? Every method below maps to one endpoint you can call directly — see Making requests.
Prerequisites
- Node 18 or newer (uses the built-in
fetch) - A cloro API key from the dashboard (see Authentication)
Install the package
Configure your API key
Set the key as an environment variable — the client readsCLORO_API_KEY automatically:
Quickstart
{ success, result } envelope. Pass include: {...} to request extra formats (markdown, html, searchQueries, shopping, and more, depending on the engine).
Every engine, one client
AI engines take aprompt; Google Search and Google News take a query. Each method is a thin wrapper over one endpoint.
| Method | Endpoint |
|---|---|
client.monitor.google({ query, country }) | POST /v1/monitor/google |
client.monitor.chatgpt({ prompt, country }) | POST /v1/monitor/chatgpt |
client.monitor.gemini({ prompt, country }) | POST /v1/monitor/gemini |
client.monitor.perplexity({ prompt, country }) | POST /v1/monitor/perplexity |
client.monitor.copilot({ prompt, country }) | POST /v1/monitor/copilot |
client.monitor.grok({ prompt, country }) | POST /v1/monitor/grok |
client.monitor.aimode({ prompt, country }) | POST /v1/monitor/aimode |
client.monitor.googleNews({ query, country }) | POST /v1/monitor/google/news |
client.monitor.google also accepts location, uule, device, and pages (1–20). The client exposes client.countries() and client.states() for the supported countries and states.
client.monitor.grok is available, but the provider is temporarily unavailable — calls to it will fail until Grok access is restored.Async task queue
For large batches, don’t loop synchronous calls — enqueue tasks and poll them.createBatch submits up to 500 tasks in one request; wait polls a task to completion with interval backoff. See Async requests.
client.asyncTasks.run({ taskType, payload }) creates it and resolves once it completes. Valid taskType values: CHATGPT, GEMINI, PERPLEXITY, COPILOT, GROK, AIMODE, GOOGLE, GOOGLE_NEWS.
Reliability and configuration
The client retries timeouts, connection errors, and429/5xx responses with exponential backoff — tune it with new Cloro({ maxRetries: 2, timeout: 60000 }) (timeout in milliseconds). Cap your own concurrency to your plan’s limit (see Concurrency), read the key from CLORO_API_KEY rather than hardcoding it, and access response fields with optional chaining (?.) since shapes vary by query (a Google result with no AI Overview omits aioverview).
Error handling
Every error subclassesCloroError, so one instanceof CloroError check catches everything. HTTP failures map to status-specific types:
| Exception | Meaning |
|---|---|
AuthenticationError | 401 — missing or invalid API key |
BadRequestError | 400 — malformed request or failed validation |
PermissionDeniedError | 403 — key not allowed for this action |
NotFoundError | 404 — resource does not exist |
ConflictError | 409 — conflicts with current state (e.g. concurrency limit) |
RateLimitError | 429 — too many requests |
InternalServerError | 5xx — the API failed to process the request |
APITimeoutError | request timed out before a response |
TaskFailedError / TaskTimeoutError | async task failed, or did not finish within the poll timeout |
Related
- JavaScript & Node API guide — the landing-page walkthrough with recipes, pricing, and production patterns
- Python SDK — the same client surface in Python
- Google SERP API — the SERP endpoint this SDK wraps
Next steps
- Making requests — the raw sync and async HTTP contracts
- Providers and Billing & credits — per-engine credit costs
- API reference — full request and response schemas
- cloro-node on GitHub and on npm