Skip to main content

API client for Safelyx.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a month ago (0.1.0)

Safelyx API

deno npm jsr

Safelyx API client

Safelyx API client for Deno, Node/NPM and browser. It has no dependencies.

You can find the API documentation at https://safelyx.com/safe-api.

Some things to note:

  1. It's simply making an HTTP request to the Safelyx API.

  2. It provides types (and examples in JSDoc) for the results and for the parameters.

  3. If the request to the API fails (HTTP error), it will throw an error, so you might want to wrap it in a try/catch block.

Usage

It has a method per API endpoint.

Deno

import safelyx from 'jsr:@safelyx/api@0.1.0'; // or import safelyx from 'https://deno.land/x/safelyx@0.1.0/mod.ts';

const checkResult = await safelyx.checkLink('https://example.com');

console.log(checkResult.result); // Outputs a safety score between 0 (unsafe) and 10 (safe). -1 if there was an error, -2 if there are no checks remaining.

Node/NPM

npm install --save-exact @safelyx/api
const safelyx = require('@safelyx/api'); // or import safelyx from '@safelyx/api';

const checkResult = await safelyx.checkLink('https://example.com');

console.log(checkResult.result); // Outputs a safety score between 0 (unsafe) and 10 (safe). -1 if there was an error, -2 if there are no checks remaining.

Development

Requires deno.

make format
make test

Publishing

After committing and pushing with a new version in deno.json, just run make publish.

Add Package

deno add jsr:@safelyx/api

Import symbol

import * as api from "@safelyx/api";

---- OR ----

Import directly with a jsr specifier

import * as api from "jsr:@safelyx/api";

Add Package

npx jsr add @safelyx/api

Import symbol

import * as api from "@safelyx/api";

Add Package

yarn dlx jsr add @safelyx/api

Import symbol

import * as api from "@safelyx/api";

Add Package

pnpm dlx jsr add @safelyx/api

Import symbol

import * as api from "@safelyx/api";

Add Package

bunx jsr add @safelyx/api

Import symbol

import * as api from "@safelyx/api";