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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file pasteconnect-0.6.2.tar.gz.

File metadata

  • Download URL: pasteconnect-0.6.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for pasteconnect-0.6.2.tar.gz
Algorithm Hash digest
SHA256 0524d090bc3c955ececf0a779fc2689b29822d0c3c440a157c39be836c71f02e
MD5 a89dccd70f5b14ec434e9de71248a707
BLAKE2b-256 16094e96c47f5d355b186a9d9062a33bb52eb0bbb3439d23fbfc459c9c391184

See more details on using hashes here.

File details

Details for the file pasteconnect-0.6.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pasteconnect-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1970c2405269990b49cb466f06754ffcc80d0b8be605dff3520386caa7524519
MD5 d51a4a809b3c2295e1e67574c64186ea
BLAKE2b-256 8bb6bca34c73a43b577963cf4e51acfe326947a41c48ddfe218b6df2161a1396

See more details on using hashes here.

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