Socket
Socket
Sign inDemoInstall

@qgisk/jokeapi-wrapper

Package Overview
Dependencies
7
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @qgisk/jokeapi-wrapper

Wrapper for Joke API


Version published
Maintainers
1
Created

Readme

Source

Joke API Client for NodeJS

NPM version NPM downloads

A Node.js wrapper for the JokeAPI with only one dependency.

• Installation

npm i @qgisk/jokeapi-wrapper

• JokeAPI Documentation

For complete API documentation, up-to-date parameters, responses and errors, please refer to JokeAPI

• Constants

This module provides helper constants for use in calls.

KeyUsageDescription
BASEJokeAPI.BASEBase url for api
HOSTJokeAPI.HOSTHost url
API_VERSIONJokeAPI.API_VERSIONCurrent api version
CATEGORIESJokeAPI.CATEGORIESLists all avaliable categories
BLACKLIST_FLAGSJokeAPI.BLACKLIST_FLAGSLists all avaliable blacklist flags
FORMATJokeAPI.FORMATLists all avaliable formats
TYPEJokeAPI.TYPELists all avaliable types
AMOUNT_MAXJokeAPI.AMOUNT_MAXMax amount of jokes per request

• Quick Start Example

// Import the wrapper library
const JokeAPI = require('@qgisk/jokeapi-wrapper');

// Initiate the client
const JokeClient = new JokeAPI();

// Create a function that gets a joke
const get = async () => {
  const joke = await JokeClient.getJoke();
  console.log(joke);
};

// Execute the function
get();

• With Options

KeyType
apiKeystring
safemodeboolean
formatstring
blacklistFlagsstring/array
langstring

• Example

const JokeClient = new JokeAPI({ apiKey: 'exampleapikey', safemode: true, format: 'xml' blacklistflags: ['nsfw'], lang: 'de'});

• Categories & BlacklistFlags

can be given in an array or a string seperated by ,

• Example

const JokeClient = new JokeAPI({ blacklistflags: ['nsfw', 'explicit'] });
const joke = await JokeClient.getJoke({ categories: 'coding,dark' });

• Get Joke

KeyType
categoriesstring/array
formatstring
blacklistFlagsstring/array
langstring
idRangenumber
containsstring
typestring
amountnumber

• Example

const joke = await JokeClient.getJoke({ categories: ['Coding', 'dark'] });

or

const joke = await JokeClient.getJoke({ categories: 'Coding,dark' });

or

// If theres no categories provided it defaults to /any
const joke = await JokeClient.getJoke();

• Info

KeyType
formatstring
langstring

• Example

const info = await JokeClient.info();

or

const info = await JokeClient.info({ format: 'text', lang: 'en' });

• Categories

KeyType
formatstring
langstring

• Example

const categories = await JokeClient.categories();

or

const categories = await JokeClient.categories({ format: 'text', lang: 'en' });

• Langcode

KeyType
formatstring
languagestring

• Example

const langcode = await JokeClient.langcode();

or

const langcode = await JokeClient.langcode({ format: 'text', language: 'english' });

• Languages

KeyType
formatstring
langstring

• Example

const languages = await JokeClient.languages();

or

const languages = await JokeClient.languages({ format: 'text', lang: 'en' });

• Flags

KeyType
formatstring
langstring

• Example

const flags = await JokeClient.flags();

or

const flags = await JokeClient.flags({ format: 'text', lang: 'en' });

• Formats

KeyType
formatstring
langstring

• Example

const formats = await JokeClient.formats();

or

const formats = await JokeClient.formats({ format: 'text', lang: 'en' });

• Ping

KeyType
formatstring
langstring

• Example

const ping = await JokeClient.ping();

or

const ping = await JokeClient.ping({ format: 'text', lang: 'en' });

• Submitting

For testing define dry-run as anything

• Example

const submitSingle = await JokeClient.submit({
  'dry-run': true,
  formatVersion: 3,
  category: 'Misc',
  type: 'single',
  joke: 'testing',
  flags: { nsfw: true, religious: false, political: false, racist: false, sexist: false, explicit: true },
  lang: 'en',
});
const submitDouble = await JokeClient.submit({
  'dry-run': true,
  formatVersion: 3,
  category: 'misc',
  type: 'twopart',
  setup: 'Setup',
  delivery: 'Delivering',
  flags: { nsfw: true, religious: false, political: false, racist: false, sexist: false, explicit: true },
  lang: 'en',
});

• Inspiration

miscavage

• License

MIT

Keywords

FAQs

Last updated on 09 Aug 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc