Skip to main content

A JavaScript client for Google Safe Browsing API

Works with
This package works with Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
JSR Score
100%
Published
3 months ago (1.0.7)

google-safe-browsing

A JavaScript client for Google Safe Browsing API (https://developers.google.com/safe-browsing)

Features

  • Zero dependencies
  • Built-in support for Edge runtime
  • Typesafe with TypeScript
  • Supports all Google Safe Browsing API v4 endpoints
  • Fully documented

APIs

findThreadMatches

Finds the threat entries that match the Safe Browsing lists.

import { findThreadMatches } from '@hckhanh/google-safe-browsing'

const result = await findThreadMatches('apiKey', {
  client: {
    clientId: 'uniqueClientId',
    clientVersion: '1.0.0',
  },
  threatInfo: {
    threatTypes: ['MALWARE', 'SOCIAL_ENGINEERING'],
    platformTypes: ['ALL_PLATFORMS'],
    threatEntryTypes: ['URL'],
    threatEntries: [
      { url: 'http://malware.testing.google.test/testing/malware/' },
    ],
  },
})

const hasRisk = result.matches !== undefined && result.matches.length > 0

Release Notes

You can go to Releases page to see the release notes.

Note

The Safe Browsing API is for non-commercial use only. If you need to use APIs to detect malicious URLs for commercial purposes - meaning 'for sale or revenue-generating purposes' - please refer to the Web Risk API.

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add @hckhanh/google-safe-browsing

Import symbol

import * as mod from "@hckhanh/google-safe-browsing";

Add Package

npx jsr add @hckhanh/google-safe-browsing

Import symbol

import * as mod from "@hckhanh/google-safe-browsing";

Add Package

yarn dlx jsr add @hckhanh/google-safe-browsing

Import symbol

import * as mod from "@hckhanh/google-safe-browsing";

Add Package

pnpm dlx jsr add @hckhanh/google-safe-browsing

Import symbol

import * as mod from "@hckhanh/google-safe-browsing";

Add Package

bunx jsr add @hckhanh/google-safe-browsing

Import symbol

import * as mod from "@hckhanh/google-safe-browsing";