@retrieverjs/coreEasy username availability checking |
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!