Skip to main content

Package to read and upload code/text to pastebin.com.

Project description

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

Getting Started

To get(create) your username, password » login to your pastebin account

after creating your account, head over to the api documentation and grab your api_key under Your Unique Developer API Key


Usage

from pasteconnect import PasteConn

# Sync Client
pastebin = PasteConn(username, password, api_key)
# Account_status(check validity of account)
account_status = pastebin.check_account()
print(account_status)

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

# Paste text to pastebin
paste_url = pastebin.create_paste(title, content, privacy=1)
print(f"Paste created: {paste_url}")

Initialize client

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

-required for other modules to work

Username Password Api_key

Refer Getting Started

username = "username"
password = "*******"
api_key = "123456abcdefg"
# Define 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

pastebin.check_account()

dash

Check validity of pastebin.com account.

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

Authentication

To authenticate and get your user_key:

pastebin.auth()

dash

Get user_key using give credentials.

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

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

privacy title content

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

pastebin.delete_paste(url)

Static Badge

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

Get raw content

To retrieve the raw content of a paste using its 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/kZATAWhe"
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. 😁

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pasteconnect-0.6.2.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

pasteconnect-0.6.2-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page