Skip to main content
This guide follows NestJS conventions: a dedicated GeekflareModule with an injectable GeekflareService, typed request DTOs, and .env config via ConfigModule. The examples use the official @geekflare/api-node SDK.

Prerequisites

  • NestJS 10+
  • Node.js 18+
  • A Geekflare API key — get one free

Installation

Set your API key

.env
Never commit .env. Add it to .gitignore and use .env.example for documentation.

Module setup

GeekflareService

Create a service that instantiates the client once and exposes typed methods.
src/geekflare/geekflare.service.ts

GeekflareModule

src/geekflare/geekflare.module.ts

AppModule

Register ConfigModule globally so ConfigService is available everywhere, then import GeekflareModule.
src/app.module.ts

Web Scraping

DTOs

src/scrape/dto/scrape.dto.ts

Controller

src/scrape/scrape.controller.ts
Example request:

DTOs

src/search/dto/search.dto.ts

Controller

src/search/search.controller.ts
Example request:

Screenshot

DTOs

src/screenshot/dto/screenshot.dto.ts

Controller

src/screenshot/screenshot.controller.ts
Example request:

Wiring it all together

Register your feature modules in AppModule:
src/app.module.ts
Enable ValidationPipe globally in main.ts to activate the DTO decorators:
src/main.ts

Error handling

NestJS maps HttpException to the correct HTTP status automatically. For a global catch-all, add an exception filter:
src/filters/geekflare-exception.filter.ts
Register it in main.ts:

Common error codes

See Rate Limit Exceeded and Credit Exhausted for strategies to handle these gracefully.

Next steps