0.2.0 • Published 6 years ago

@spamblockers/api v0.2.0

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
6 years ago

SpamBlockers API JavaScript Wrapper

The official JavaScript Wrapper of SpamBlockers API, forked from the SpamWatch API JavaScript Wrapper, with some customizations.

Changelog

v0.2.0

  • Updated the README to include changelog, available functions and credits, among other things.
  • Renamed some functions for clarifications.

v0.1.0

Installtion

Just install the package with npm i, like this:

## This will save to your package.json, just in case you publish
## your source code KEK.
npm i @spamblockers/api --save

After installation, you can just require and call API requests, like this one below.

With SpamWatch API JS Wrapper

As usual, install it with npm.

## This will save to your package.json, just in case you publish
## your source code KEK.
npm i spamwatch --save

After installation, you can just require and call API requests, like this one below.

Basic Usage

const SpamBlockersApi = require('@spamblockers/api');
const token = process.env.SPAMBLOCKERS_API_TOKEN
const client = new SpamBlockersApi.Client(token);

(async () => {
    const ban = await client.queryBanStatus(777000);
    console.log(ban);
})();

In this example, when we ran this query, the resulting response will be:

{
    ok: false,
    description: 'This user was whitelisted, so Telegram is not banned.'.
    userId: 777000,
    isBanned: false,
    banned_by: null,
    reason: null,
    timestamp: null
}

Using SpamWatch JS Wrapper

This may be different, because you need to point host to SpamBlockers API host.

const SpamWatch = require('spamwatch');
const SpamBlockersApi = 'https://api.spamblockers.bot';
const token = process.env.SPAMBLOCKERS_API_TOKEN;
const client = new SpamBlockersApi.Client(token, SpamBlockersApi);

(async () => {
    const ban = await client.queryBanStatus(777000);
    console.log(ban);
})();

Available Functions

As soon as the SpamWatch API wrapper for JavScript have new functions to use, we'll update our code here. For in a meanwhile,

CategoryNamePermission LevelIn this packageIn SpamWatch API JS WrapperSupported Since (from the API wrapper version history)
BlacklistPulling the whole banlistRootexportAllBansgetBans0.1.0
Querying a user's ban status.UserqueryBanStatusgetBan0.1.0
Getting a list of banned IDsUserUnsupported, coming soonUnsupported, coming soon.n/a
Banning a user thru APISudo/AdminaddNewGbanaddBan0.1.0
Batch banning users thru API.Sudo/AdminbatchGbanaddBans0.1.0
Unbanning a user thru APISudo/AdminremoveGbandeleteBan0.1.0
API Tokens ManagementGetting your token's metadata.UserpullSelfMetagetSelf0.1.0
Getting all tokensRootgetAllApiTokensgetTokens0.1.0
Getting a specific token and its metadataRootgetApiTokenMetadatagetToken0.1.0
Generating a new tokenSudo/AdmingenerateApiTokencreateToken0.1.0
Revoke a tokenRootrevokeApiTokendeleteToken0.1.0
MiscGetting API versionNo Authenication Neededversionversion0.1.0
Getting API statsNo Authenication Neededstatsstats0.1.0

Examples

For a list of examples for available functions listed above, plese see the examples directory of the packge's source code.

Is this backwards-compartible with SpamWatch API?

Yes, you can call the SpamWatch API using the SpamBlockers API JS Wrapper, but you need to change the host to https://api.spamwat.ch, like this:

const SpamBlockersApi = require('@spamblockers/api');
const token = process.env.SPAMBLOCKERS_API_TOKEN;
const host = "https://api.spmwat.ch";
const client = new SpamBlockersApi.Client(token);

(async () => {
    const ban = await client.queryBanStatus(777000);
    console.log(ban);
})();

Credits

0.2.0

6 years ago

0.1.0

6 years ago