This package has been deprecated

Author message:

Service has been shut down

bananapi
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

BananAPI.js

install size npm

A wrapper to use the https://bananapi.ml API which has some fun endpoints

Install

npm install bananapi

API Key

You need a key to use this API to get one, we use discordapp to manage users and give out api keys so to apply you need to join our discord server using the link https://discord.gg/3Nxb7yZ and once your in run b.apply command by sending it in chat

Usage

const BananAPI = require("bananapi");
const fs = require("fs").promises;
const api = new BananAPI.Client({ token: "Your Token Goes here" });
 
(async() => {
 
  // Ping API for reponse time
  const ping = await api.ping();
  console.log(`Pong! ${ping} ms`);
 
  const reversed = await api.reverse("Hello, World!");
  console.log(reversed);
  const eball = await api.eightball("Some question?");
  console.log(`8ball: ${eball.response}, positive: ${eball.isPositive}`);
 
  // Image endpoints
  const image = await api.trumptweet("Hello");
  await fs.writeFile("./image.png", image);
});

Discord.js example, sending attachments

// Note we required both but you need just one depending on your version
// v11.x.x stable is Attachment
// v12.0.0 dev is MessageAttachment
const { Attachment, MessageAttachment } = require("discord.js");
 
const image = await api.disabled("something");
message.channel.send(new MessageAttachment(image, "file.png"));

TypeScript

TypeScript typings gets installed by default, you can use it straight with TypeScript and even if you are not the typings gives a nice intellisense code suggestion on editors like Visual Studio Code

Here is an example using TypeScript

import { Client } from "bananapi";
 
const client: Client = new Client({ token: "my token" });
 
client.reverse("TypeScript")
  .then((reversed: string) => {
    console.log(reversed); // => tpircSepyT
  });

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i bananapi

Weekly Downloads

3

Version

1.3.0

License

MIT

Unpacked Size

11.2 kB

Total Files

7

Last publish

Collaborators

  • ravener