Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.geekflare.com/llms.txt

Use this file to discover all available pages before exploring further.

The official @geekflare/api-node SDK gives you full TypeScript support and handles auth, serialization, and response parsing out of the box. Raw fetch examples are included for dependency-free setups.

Prerequisites

  • Node.js 18+ (native fetch is stable from v18)
  • A Geekflare API key — get one free

Installation

bash pnpm add @geekflare/api-node

Set your API key

Create a .env file at your project root:
.env
GEEKFLARE_API_KEY=your_api_key_here
Never commit your .env file. Add it to .gitignore.

Initialize the client

import { GeekflareClient } from "@geekflare/api-node";

const client = new GeekflareClient({
  apiKey: process.env.GEEKFLARE_API_KEY!,
});

Web Scraping

Scrape the full content of any URL. Returns HTML, Markdown, and more depending on the format you request.
import { GeekflareClient } from "@geekflare/api-node";

const client = new GeekflareClient({
  apiKey: process.env.GEEKFLARE_API_KEY!,
});

const result = await client.webScrape({
  url: "https://toscrape.com/",
  device: "desktop",
  renderJS: true,
  blockAds: true,
  format: "html,markdown",
});

console.log(result);
Key parameters:
ParameterTypeDescription
urlstringRequired. The URL to scrape
device"desktop" | "mobile"Emulate device type
renderJSbooleanWait for JavaScript to execute
blockAdsbooleanBlock ads before scraping
formatstringComma-separated: html, markdown
proxyCountrystringRoute via country code, e.g. "us"
stealthbooleanEnable stealth mode
waitTimenumberExtra wait time in seconds
Example response:
{
  "timestamp": 1779703261268,
  "apiStatus": "success",
  "apiCode": 200,
  "meta": {
    "url": "https://toscrape.com/",
    "device": "desktop",
    "format": ["html-llm"],
    "blockAds": true,
    "renderJS": true,
    "stealth": false,
    "test": { "id": "mxqx9v9y0742lap6altwdteqd28t23nq" }
  },
  "data": "https://example.com/9bulgk075ed9m3vhua5vcrp0.html"
}
The data field is a URL to the scraped output file. For full response details, see the Web Scraping endpoint reference.
Run a web search and get ranked results with titles, URLs, and descriptions.
import { GeekflareClient } from "@geekflare/api-node";

const client = new GeekflareClient({
  apiKey: process.env.GEEKFLARE_API_KEY!,
});

const result = await client.search({
  query: "best static site generators",
  limit: 10,
  location: "us",
  source: "web",
  time: "m",     // past month
  format: "json",
});

console.log(result);
Key parameters:
ParameterTypeDescription
querystringRequired. The search query
limitnumberNumber of results (default: 10)
locationstringCountry code for localized results, e.g. "us"
sourcestring"web", "news", etc.
timestringRecency filter: "d" (day), "w" (week), "m" (month)
includeDomainsstring[]Only return results from these domains
excludeDomainsstring[]Exclude results from these domains
groundedAnswerbooleanReturn an AI-grounded answer alongside results
Example response:
{
  "timestamp": 1779703261268,
  "apiStatus": "success",
  "apiCode": 200,
  "meta": {
    "query": "best static site generators",
    "count": 10,
    "source": "web",
    "location": "us",
    "time": "m",
    "test": { "id": "mxqx9v9y0742lap6altwdteqd28t23nq" }
  },
  "data": [
    {
      "title": "10 Best Static Site Generators in 2024",
      "url": "https://example.com/article",
      "snippet": "A comprehensive comparison of the top static site generators...",
      "date": "Dec 18, 2025",
      "position": 1,
      "content": "Full article cleaned for LLM consumption..."
    }
  ]
}

Screenshot

Capture a screenshot of any URL. Returns a hosted image URL.
import { GeekflareClient } from "@geekflare/api-node";

const client = new GeekflareClient({
  apiKey: process.env.GEEKFLARE_API_KEY!,
});

const result = await client.screenshot({
  url: "https://example.com",
  type: "png",
  fullPage: true,
  device: "desktop",
  viewportWidth: 1280,
  viewportHeight: 800,
  blockAds: true,
  hideCookie: true,
  quality: 90,
});

console.log(result);
Key parameters:
ParameterTypeDescription
urlstringRequired. The URL to capture
type"png" | "jpg" | "webp"Output image format
fullPagebooleanCapture beyond the visible viewport
device"desktop" | "mobile"Device emulation
viewportWidthnumberViewport width in pixels
viewportHeightnumberViewport height in pixels
blockAdsbooleanRemove ads before capture
hideCookiebooleanHide cookie consent banners
skipCaptchabooleanAttempt to bypass CAPTCHA overlays
delaynumberWait (seconds) before capture
qualitynumberImage quality 1–100 (JPEG/WebP)
removeBackgroundbooleanRemove background (PNG only)
Example response:
{
  "timestamp": 1779703261268,
  "apiStatus": "success",
  "apiCode": 200,
  "meta": {
    "url": "https://example.com",
    "type": "png",
    "device": "desktop",
    "fullPage": true,
    "blockAds": true,
    "hideCookie": true,
    "viewportWidth": 1280,
    "viewportHeight": 800,
    "quality": 90,
    "test": { "id": "mxqx9v9y0742lap6altwdteqd28t23nq" }
  },
  "data": "https://geekflare.com/tests/screenshot/kbi6d206g87ituahb7icwtpr.png"
}
The data field is a direct URL to the screenshot image. See the Screenshot endpoint reference.

Error handling

The SDK throws on API errors. Wrap calls in try/catch and inspect the error for actionable codes.
import { GeekflareClient } from "@geekflare/api-node";

const client = new GeekflareClient({
  apiKey: process.env.GEEKFLARE_API_KEY!,
});

try {
  const result = await client.webScrape({ url: "https://toscrape.com/" });
  console.log(result);
} catch (error: any) {
  console.error("API error:", error);

  const code = error?.apiCode ?? error?.status;

  switch (code) {
    case 401:
      console.error("Invalid or missing API key.");
      break;
    case 402:
      console.error("API credits exhausted. Top up at dash.geekflare.com.");
      break;
    case 403:
      console.error("This endpoint is not available on your current plan.");
      break;
    case 429:
      console.error("Rate limit exceeded. Back off and retry.");
      break;
    default:
      console.error(`Unexpected error [${code}]:`, error.message);
  }
}

Common error codes

CodeMeaning
401Missing or invalid x-api-key header
402API credits exhausted
403Endpoint requires a higher plan
404Wrong endpoint URL or HTTP method
429Rate limit exceeded
See Rate Limit Exceeded and Credit Exhausted for strategies to handle these gracefully.

Next steps