@kreisler/createapi
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Create API

Create API is a simple package to create API requests with ease.

Usage

Install package

npm i @kreisler/createapi

Import module

import { createApi } from "@kreisler/createapi";

or

Import commonjs

const { createApi } = require("@kreisler/createapi");

Example #1

(async () => {
  // createApi
  const api = createApi('https://nekobot.xyz/api')
  const output = await api.image({ type: 'neko' })
  // final url: https://nekobot.xyz/api/image?type=neko
  console.log({ output })
  // output: 
  // {
  // "success": true,
  // "message": "https://i0.nekobot.xyz/7/0/6/217595fa8b7cae5b7f6524169230c.png",
  // "color": 13419230,
  // "version": "2021070801"
  // }
})();

Example #2

(async () => {
  // createApi
  const api = createApi('https://api.adviceslip.com')
  const output = await api.advice()
  // final url: https://api.adviceslip.com/advice
  console.log({ output })
  /**
   * {
   * output: { slip: { id: 189, advice: 'Do not compare yourself with others.' } }
   * }
  */
})();

Package Sidebar

Install

npm i @kreisler/createapi

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

9.13 kB

Total Files

6

Last publish

Collaborators

  • kreisler