ESM
import PasteClient from "pastebin-api";
const client = new PasteClient("DEV_API_KEY");
CommonJS
const PasteClient = require("pastebin-api").default;
const client = new PasteClient("DEV_API_KEY");
Name | Type | Description | Required |
---|---|---|---|
apiKey |
string |
Your dev api key | true |
domain |
string |
Optional domain name to a custom pastebin API | false |
import { PasteClient, Publicity, ExpireDate } from "pastebin-api";
const client = new PasteClient("DEV_API_KEY");
const url = await client.createPaste({
code: "const something = 'Hello World!'",
expireDate: ExpireDate.Never,
format: "javascript",
name: "something.js",
publicity: Publicity.Public,
});
console.log(url);
Name | Type | Description | Required |
---|---|---|---|
code |
string |
The code you want to push | true |
expireDate |
string |
Sets the expire date of the paste | false |
format |
string |
The Syntax format | false |
name |
string |
The name of your paste (Limit of 100 characters) | false |
publicity |
number |
0 | 1 | 2 |
false |
folderKey |
string |
The folder key(id) | false |
apiUserKey |
string |
The user key gotten from PasteClient#login | false |
const client = new PasteClient("DEV_API_KEY");
const token = await client.login({ name: "user_name", password: "user_password" });
// This is the user token that can be used to get all the user's pastes or delete one
console.log(token);
Name | Type | Description | Required |
---|---|---|---|
name |
string |
The user’s name | true |
password |
string |
The user’s password | true |
const client = new PasteClient("DEV_API_KEY");
// Login to get the token
const token = await client.login({ name: "user_name", password: "user_password" });
// Get a limit of 1000 pastes from the user
const pastes = await client.getPastesByUser({
userKey: token,
limit: 100, // Min: 1, Max: 1000
});
// An array of pastes
console.log(pastes);
Name | Type | Description | Required |
---|---|---|---|
userKey |
string |
The token returned from PasteClient#login | true |
limit |
number |
The limit of pastes to get | false |
const client = new PasteClient("DEV_API_KEY");
// Login to get the token
const token = await client.login({ name: "user_name", password: "user_password" });
// Will return a boolean if deleted
const deleted = await client.deletePasteByKey({
userKey: token,
pasteKey: "paste-key-here",
});
//=> `true` or `false`
console.log(deleted);
Name | Type | Description | Required |
---|---|---|---|
userKey |
string |
The token returned from PasteClient#login | true |
pasteKey |
string |
The key (id) of the paste | true |
const client = new PasteClient("DEV_API_KEY");
// Login to get the token
const token = await client.login({ name: "user_name", password: "user_password" });
const data = await client.getRawPasteByKey({
pasteKey: "paste-key-here",
userKey: token,
});
//=> raw paste string
console.log(data);
Name | Type | Description | Required |
---|---|---|---|
userKey |
string |
The token returned from PasteClient#login | true |
pasteKey |
string |
The key (id) of the paste | true |
Value | Type | Description |
---|---|---|
0 |
number |
This paste will be public and listed |
1 |
number |
This paste will be unlisted |
2 |
number |
The paste will be private (Only available when logged in) |
Value | Type | Description |
---|---|---|
N |
string |
Never |
10M |
string |
10 Minutes |
1H |
string |
1 Hour |
1D |
string |
1 Day |
1W |
string |
1 Week |
2W |
string |
2 Weeks |
1M |
string |
1 Month |
6M |
string |
6 Months |
1Y |
string |
1 Year |