Sign In

@middlebrick/api-client

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@middlebrick/api-client

middleBrick API client — zero-dependency, native fetch

latest
npmnpm
Version
0.1.0
Version published
Weekly downloads
13
-7.14%
Maintainers
1
Weekly downloads
 
Created
Source

@middlebrick/api-client

Zero-dependency TypeScript client for the middleBrick API security scanning platform. Uses native fetch — works in Node.js, Cloudflare Workers, and browsers.

Install

npm install @middlebrick/api-client

Quick Start

import { MiddleBrickClient } from "@middlebrick/api-client";

const client = new MiddleBrickClient({
  apiKey: "mb_your_key_here",
});

// Scan and wait for results
const result = await client.scanAndWait({
  apiUrl: "https://api.example.com/v1/users",
  method: "GET",
});

console.log(result.overall); // 72
console.log(result.letterGrade); // "C"
console.log(result.findings); // [{ severity: "high", title: "...", ... }]

API

new MiddleBrickClient(opts)

OptionTypeRequiredDescription
apiKeystringYesYour middleBrick API key
baseUrlstringNoAPI base URL (default: https://middlebrick.com)

Methods

scanApi(params) — Submit a scan

Returns { scanId: string }. Does not wait for completion.

getScan(scanId) — Get scan results

Returns a ScanResult with score, grade, categories, and findings.

listScans(params?) — List previous scans

Optional filters: limit, offset, status. Returns ScanListResult.

scanAndWait(params, opts?) — Scan and poll until done

Submits a scan and polls until completed or failed. Default timeout: 5 minutes.

Error Handling

import { MiddleBrickClient, MiddleBrickError } from "@middlebrick/api-client";

try {
  const result = await client.scanAndWait({ apiUrl: "https://api.example.com" });
} catch (err) {
  if (err instanceof MiddleBrickError) {
    console.error(err.message); // "Unauthorized"
    console.error(err.statusCode); // 401
  }
}

Types

All types are exported: ScanResult, ScanListResult, ScanListItem, Finding, LetterGrade, Severity, PatentDimensions, ClientOptions, ScanParams, ListScansParams.

License

MIT — Zevlat Intelligence

FAQs

Package last updated on 16 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts