Coder Social home page Coder Social logo

casperiv0 / pastebin-api Goto Github PK

View Code? Open in Web Editor NEW
28.0 1.0 6.0 829 KB

A very simple pastebin npm package to interact with the pastebin api!

Home Page: https://www.npm.im/pastebin-api

License: MIT License

TypeScript 100.00%
hastebin pastebin pastebin-api npm-package

pastebin-api's Introduction

pastebin-api

License Downloads

A very simple npm package to interact with the pastebin api.

Features

  • Create pastes with all the available API data
  • Fetch the raw contents of a paste
  • Fetch pastes from the authenticated user via a user login
  • Delete pastes from the authenticated user via a user login

Installation

# npm
npm install pastebin-api

# Yarn
yarn add pastebin-api

# pnpm
pnpm add pastebin-api

Note > pastebin-api requires node.js version 14 or higher.

Usage

// src/main.js
import { PasteClient, Publicity, ExpireDate } from "pastebin-api";
// const { PasteClient, Publicity, ExpireDate } = require("pastebin-api"); // using CommonJS

// Tip: load dev key from a `.env` file
const client = new PasteClient("DEV_KEY_HERE");

/* ... */

Documentation

You can checkout the documentation here

Support

All stars/forks are appreciated! ⚡

Feel free to open a pull request with a new feature.

Made with ❤️ and TypeScript!

License

MIT © Casper Iversen

pastebin-api's People

Contributors

alpazified avatar casperiv0 avatar dependabot[bot] avatar mrdgh2821 avatar zxilly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pastebin-api's Issues

getRawPasteByKey() not working as expected

Somehow the function is not working on my end as expected.

I want to get raw data, but this function returns Bad API request, invalid api_user_key

I'm using this library in my Discord bot. The Beta version is throwing error when used at this place

In my "stable" version of bot, it is working as expected.

The Link in question: https://pastebin.com/CHPktxqT

issue while "Get pastes from user"

every time try to get a user paste gives me an error

(node:14220) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

pls help

Error while logging in using name and password

On executing the following code:

const client = new PasteClient(process.env.PASTEBIN_DEV_KEY ?? "");

const token = await client.login(process.env.PASTEBIN_USERNAME ?? "", process.env.PASTEBIN_PASSWORD ?? "").catch((err) => {
  console.error(err);
});
console.log(token);

It gives the following error:

Error: Not supported
                      at fetch (D:\CLI Tools\Markdown-HTML Generator\node_modules\pastebin-
api\dist\index.js:36:31)
                      at PasteClient.login (D:\CLI Tools\Markdown-HTML Generator\node_modules\pastebin-
api\dist\index.js:166:23)
                      at D:\CLI Tools\Markdown-HTML Generator\lib\commands\init.js:92:22
                      at step (D:\CLI Tools\Markdown-HTML Generator\lib\commands\init.js:33:23)
                      at Object.next (D:\CLI Tools\Markdown-HTML Generator\lib\commands\init.js:14:53)
                      at D:\CLI Tools\Markdown-HTML Generator\lib\commands\init.js:8:71
                      at new Promise (<anonymous>)
                      at __awaiter (D:\CLI Tools\Markdown-HTML Generator\lib\commands\init.js:4:12) 
                      at Command.init (D:\CLI Tools\Markdown-HTML Generator\lib\commands\init.js:86:33)
                      at Command.listener [as _actionHandler] (D:\CLI Tools\Markdown-HTML Generator\node_modules\commander\lib\command.js:488:17)

Note that process.env.PASTEBIN_DEV_KEY, process.env.PASTEBIN_USERNAME and process.env.PASTEBIN_PASSWORD are all defined (non-null).

Please provide solution to this issue at your earliest convenience. Also let me know if I am doing something wrong.

Edit

Add the function to edit a paste

Setting name property doesn't work, simply uploads with name "Untitled"

This is the code for the encoding command in my discord bot:

const purl = await pclient.createPaste({
  name: `${origString} encoded in WorstCode(TM)(R)(c)2069(lol)`,
  code: `${s5}`,
  expireDate: "N",
  publicity: 1,
});

origString and s5 are the original string and final output, respectively. When I upload the output to pastebin with this package, the title is ignored and it uploads with the title of "Untitled" instead.

Any possible functionality to get Raw data from given URL?

Any possible functionality to get Raw data from given URL?

There's a module pastebin-scraper which fetches raw data (& other statistics) and returns it.

I attempted to replicate this functionality (by forking & adding the relavent code in pastebin-api) but I can't understand how to test it.

Was there any existing way to fetch raw data simply by provided URL?

"Cannot find module" on version 6.0.0

Hi Casper,

when I upgraded to version 6.0.0, I got the following error at my import statement:

import { PasteClient } from 'pastebin-api';

cannot find module 'pastebin-api' or its corresponding type declarations

Indeed, there seems to be something wrong about this release: under the node_modules folder of this module, there used to be a dist folder. Now there is nothing instead.

Could you please look into this problem?

I don't think this is environment specific but for good manners: running Node v18.7.0 with Yarn 1.22.19, on a WSL Ubuntu 20.04 (5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.