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.
Installation
Python 3.7 or higher is required.
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 accountafter 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)
-required for other modules to work
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()
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()
Get user_key
using give credentials.
result = pastebin.auth()
print(result) # Response: "user_key"
pastebin.create_paste(title, content, privacy=1)
# 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)
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)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0524d090bc3c955ececf0a779fc2689b29822d0c3c440a157c39be836c71f02e |
|
MD5 | a89dccd70f5b14ec434e9de71248a707 |
|
BLAKE2b-256 | 16094e96c47f5d355b186a9d9062a33bb52eb0bbb3439d23fbfc459c9c391184 |
File details
Details for the file pasteconnect-0.6.2-py3-none-any.whl
.
File metadata
- Download URL: pasteconnect-0.6.2-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1970c2405269990b49cb466f06754ffcc80d0b8be605dff3520386caa7524519 |
|
MD5 | d51a4a809b3c2295e1e67574c64186ea |
|
BLAKE2b-256 | 8bb6bca34c73a43b577963cf4e51acfe326947a41c48ddfe218b6df2161a1396 |