@retrieverjs/core
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

@retrieverjs/core

Easy username availability checking

Buy Me a Coffee at ko-fi.com

Installation

npm i @retrieverjs/core

# or

yarn add @retrieverjs/core

Usage

import { Retriever } from '@retrieverjs/core';

import type { IRetrieverResult } from '@retrieverjs/core';

const retriever = new Retriever();

retriever.on('results', (results: IRetrieverResult[]) => console.log(results));

// Check all sites
await retriever.checkUsernameAvailability('username');

// Or specific ones
await retriever.checkUsernameAvailability('username', ['deviantart', 'vimeo']);

Other events

retriever.on('started', (username: string) => console.log('Checking username', username));
retriever.on('siteCheckStarted', (url: string) => console.log('Started checking site', url));
retriever.on('siteCheckResults', (url: string, result: IRetrieverResult) => console.log('Got results from site:', results));

Adding custom sites

import { Retriever, RetrieverCheckType } from '@retrieverjs/core';

const myCustomSites = [
	{
		name: 'My Site',
		type: RetrieverCheckType.HTTP,
		followRedirects: false, // true by default
		checkOnMobile: false, // false by default
		minimumLength: 6, // 3 by default
		maximumLength: 36, // 36 by default
		errorValue: 404, // HTTP status code if type is RetrieverCheckType.HTTP or string if RetrieverCheckType.HTML
		url: 'https://my-site.dev/%s', // URL to check
		probeURL: 'https://my-site.dev/api/getUsername/%s', // An optional, alternative URL to check instead if url doesn't suffice
	}
];

const retriever = new Retriever(myCustomSites);

console.log(retriever.getSitesNames());
console.log(retriever.getSites());

Current Supported Sites

  • Bandcamp
  • DeviantArt
  • Fandom
  • Gfycat
  • Giphy
  • GitHub
  • Gravatar
  • League of Legends (all regions)
  • Medium
  • MyAnimeList
  • Newgrounds
  • NPM
  • Pastebin
  • Patreon
  • SoundCloud
  • Steam profile and group
  • Telegram short URL
  • TikTok
  • Tumblr
  • Twitch
  • Vimeo
  • Wikipedia

More sites will be added over time. If one is missing then open an issue!

Readme

Keywords

none

Package Sidebar

Install

npm i @retrieverjs/core

Weekly Downloads

1

Version

1.0.6

License

ISC

Unpacked Size

133 kB

Total Files

81

Last publish

Collaborators

  • npm