Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

CryptoScamDB/api

Open more actions menu

Repository files navigation

API

A Javascript wrapper for the CryptoScamDB API for Node.js and browser applications.

Usage

npm i -P @cryptoscamdb/api

API

Options

  • cache.enable (default: false) - Enable or disable the cache
  • cache.cacheProvider (default: MemoryCacheProvider, in-memory caching) - Set the cache provider
  • cache.cacheDuration (default: 600000) - Set the duration in milliseconds to cache a result for

Methods

All methods return a promise.

  • check(query: string) - Check a domain, Ethereum address or IP address
  • getAllScams() - Get a list of all scams
  • getAllScamsByAddress() - Get a list of all scams mapped by the Ethereum address
  • getAllScamsByIP() - Get a list of all scams mapped by the IP address

Cache provider

You can use the CacheProvider interface to implement your own caching method (e.g. filesystem or Redis).

interface CacheProvider {
    get<T = any>(key: string): Promise<T | undefined>;
    getTimestamp(key: string): Promise<number>;
    set<T = any>(key: string, result: T): Promise<boolean>;
    has(key: string): Promise<boolean>;
    remove(key: string): Promise<boolean>;
}

See cache.ts for an example (in-memory) implementation.

Example

Node.js

import CryptoScamDBAPI from '@cryptoscamdb/api';

const options = {
    cache: {
        enable: true
    }
};
const api = new CryptoScamDBAPI(options);

// Equal to https://api.cryptoscamdb.org/v1/check/example.com
api.check('example.com')
    .then(result => {
        // Do something with the result
        console.log(result.entries);
    })
    // Handle error
    .catch(console.error);

Browser

// API is available as `window.csdbapi`
const api = new window.csdbapi();

// Equal to https://api.cryptoscamdb.org/v1/check/example.com
api.check('example.com')
    .then(result => {
        // Do something with the result
        console.log(result.entries);
    })
    // Handle error
    .catch(console.error);

About

A Javascript wrapper for the CryptoScamDB API for Node.js and browser applications

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
Morty Proxy This is a proxified and sanitized view of the page, visit original site.