Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

techdetect

Lightweight client for the TechDetect Technology Detection API. Detect the tech stack of any website with a single function call.

Works in Node.js (18+) and modern browsers. Ships with TypeScript types. Supports both CommonJS and ESM.

Installation

npm install techdetect

Quick Start

import { TechDetect } from "techdetect";

const td = new TechDetect({ apiKey: "YOUR_KEY" });
const result = await td.detect("https://shopify.com");

console.log(result.technologies);
// [
//   { name: "Shopify", categories: ["ecommerce"], confidence: 1, version: null, detected_by: ["http","html"] },
//   ...
// ]

CommonJS

const { TechDetect } = require("techdetect");

const td = new TechDetect({ apiKey: "YOUR_KEY" });
td.detect("https://github.com").then((result) => {
  console.log(result.technologies);
});

Environment Variable

Instead of passing the API key directly, you can set the TECHDETECT_API_KEY environment variable:

export TECHDETECT_API_KEY=your_key_here
const td = new TechDetect(); // key read from env
const result = await td.detect("https://example.com");

API

new TechDetect(options?)

Option Type Default Description
apiKey string process.env.TECHDETECT_API_KEY API key for authentication
baseUrl string https://techdetect.dapdev.tech Base URL of the API
timeout number 30000 Request timeout in ms

td.detect(url, options?)

Scans a URL and returns the detected technologies.

Parameters:

Parameter Type Description
url string The website URL to scan
options.apiKey string Override the API key for this request
options.timeout number Override timeout for this request
options.params Record<string, string> Additional query parameters

Returns: Promise<DetectResult>

interface DetectResult {
  url: string;
  technologies: Technology[];
  meta: ScanMeta;
}

interface Technology {
  name: string;
  categories: string[];
  confidence: number;
  version: string | null;
  detected_by: string[];
}

interface ScanMeta {
  scan_time_ms: number;
  layers_used: string[];
}

Error Handling

All errors are instances of TechDetectError:

import { TechDetect, TechDetectError } from "techdetect";

const td = new TechDetect({ apiKey: "YOUR_KEY" });

try {
  const result = await td.detect("https://example.com");
} catch (err) {
  if (err instanceof TechDetectError) {
    console.error(err.message); // Human-readable message
    console.error(err.status);  // HTTP status code (if applicable)
    console.error(err.body);    // Raw error response body
  }
}

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages