Skip to content

PasteConnect is a Python library for interacting with Pastebin. It allows you to check account validity, authenticate, create pastes, delete pastes, and retrieve raw paste content.

License

Notifications You must be signed in to change notification settings

heartlog/pasteconnect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pasteconnect package

PasteConnect is a Python library for interacting with Pastebin. It allows you to check account validity, authenticate, create pastes, delete pastes, and retrieve raw paste content.

PyPI Licence

Installation

Python 3.7 or higher is required. Python

You can install PasteConnect using pip:

+$ pip install pasteconnect

Install from source repository

+$ pip install git+https://github.com/heartlog/pasteconnect.git

To use PasteConnect, you need your Pastebin credentials, which include your username, password, and api_key. If you don't have these, you can obtain them by signing up for a Pastebin account and generating an api_key from the Pastebin API documentation.

Usage

from pasteconnect import PasteConn

# Initialize a PasteConnect client
pastebin = PasteConn(username, password, api_key)
# Check account validity
account_status = pastebin.check_account()
print(account_status)

title = "My Paste Title"
content = "This is the content of my paste."

# Create a paste on Pastebin
paste_url = pastebin.create_paste(title, content, privacy=1)
print(f"Paste created: {paste_url}")

Initialize client

To interact with PasteConnect, you need to initialize a client with your credentials:

pastebin = PasteConn(username, password, api_key) Static Badge

-required for other methods to work

Username Password Api_key

Refer Getting Started

username = "your_username"
password = "your_password"
api_key = "your_api_key"

# Initialize the client
pastebin = PasteConn(username, password, api_key)

Alternatively, you can initialize with predefined environment variables

pastebin = PasteConn() # with pre define env var

Check account existance

You can check the validity of your Pastebin account using the following method:

pastebin.check_account()

dash

result = pastebin.check_account()
print(result)  # Response: '[heartlog] is Valid Account. User key : "user_key"'

Authentication

To authenticate and get your user_key, use the auth() method:

pastebin.auth()

dash

Get user_key using give credentials.

result = pastebin.auth()
print(result)  # Response: "user_key"

Creating a Paste

You can create a paste on Pastebin with a title, content, and privacy level. Privacy levels can be 0 (public), 1 (unlisted), or 2 (private):

pastebin.create_paste(title, content, privacy=1)

privacy title content

privacy = 1 # (default - private)
title = "Title of paste"
content = """
Hello
This is multiline text
"""
pastebin.create_paste(title, content, privacy=1)

Deleting a Paste

To delete a paste, provide its URL or ID using the delete_paste(url) method:

pastebin.delete_paste(url)

Static Badge

url = "https://pastebin.com/kZATAWhe"
result = pastebin.delete_paste(url)
print(result)  # Response: "Paste Removed"

Get raw content

You can retrieve the raw content of a paste using it's URL or ID:

pastebin.get_raw_content(url)

url

from pasteconnect import get_raw

result = get_raw(url)
print(result)

Alternatively, you can use the get_raw function:

url = "https://pastebin.com/your_paste_id"
result = pastebin.get_raw_content(url)
print(result)  # Response: "Content of paste"

Made with ❤️ by Heartlog

Special Thanks

venaxyt for pastebinapi. Helped a lot in project. 😁

About

PasteConnect is a Python library for interacting with Pastebin. It allows you to check account validity, authenticate, create pastes, delete pastes, and retrieve raw paste content.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages