0.2.1 • Published 8 years ago
weeb-api v0.2.1
weeb-api
Weeb-Api is a Typescript Library which makes interacting with WeebApi v2 simple and with 0 dependencies.
Installation
If using yarn,
$ yarn add weeb-api --save
If using npm,
$ npm install weeb-api --save
To use the library you need to obtain a WeebAPI token.
Examples
Get an array of all the current types:
import WeebAPI from "weeb-api";
const weebApi = new WeebAPI(process.env.TOKEN);
(async () => {
let response;
try {
response = await weebClient.getTypes();
} catch(e) {
// Handle error with request
console.log(e);
return;
}
// Do something with returned response
console.log(response);
})();
Get an array of all the current tags:
import WeebAPI from "weeb-api";
const weebApi = new WeebAPI(process.env.TOKEN);
(async () => {
let response;
try {
response = await weebClient.getTags()
} catch(e) {
// Handle error with request
console.log(e);
return;
}
//Do something with response
console.log(response);
})();
Get info on an image by its ID:
import WeebAPI from "weeb-api";
const weebApi = new WeebAPI(process.env.TOKEN);
(async () => {
let response;
try {
response = await weebClient.getImage(id)
} catch(e) {
// Handle error with request
console.log(e);
return;
}
// Do something with returned response
console.log(response);
})();
Supplying all options:
import WeebAPI from "weeb-api";
const weebApi = new WeebAPI(process.env.TOKEN);
(async () => {
let response;
try {
response = await weebClient.getRandom({
type: "kiss",
tags: "girl",
nsfw: "true",
});
} catch(e) {
// Handle error with request
console.log(e);
return;
}
// Do something with the returned response
console.log(response);
})();
Image request options:
const options = {
type: string, // Image type
tags: string, // Image tags, a list of tags seperated by commas
nsfw: string, // false(no nsfw), true(nsfw and no-nsfw), only(only nsfw)
}
License
This project is licensed under ISC.