pastebin-api
is a npm package I created to interact with the Pastebin API to create pastes, list pastes and delete pastes.
It has a very intuitive API and is very easy to use.
Installation
Creating the client
Firstly, we must import the PasteClient
class from the package:
Initializing the client
Secondly, we must initialize the client with your API key from your pastebin account
Securely storing the Pastebin API token
To securely store your Pastebin API token, I recommend you create a .env
file in the root of your project and add the following line to it:
Creating a new paste
Now we'll create a new paste using the .createPaste
method:
code
: The code we want to send in the PasteexpireDate
: When should the paste expire?format
: The format, "javascript", "java", "lua", etcname
: The name of the pastepublicity
: Whether a paste should be public, unlisted or private
Woohoo 🎉
There you have it! We've successfully created a new paste! Read more on the docs