A modern Plurk API 2.0 SDK for Python
Project description
plurk.py
A modern Python library for the Plurk API 2.0, providing an easy-to-use interface for both synchronous and asynchronous interactions.
Features
- Effortless Plurk API access with OAuth. (Code example)
- Full support for both synchronous and asynchronous API calls.
- Complete coverage of all API endpoints listed in the official documentation.
- A convenient helper function for subscribing to timeline updates. (Code example)
Requirements
- Python 3.8+
Installation
pip3 install plurk.py
Quickstart
Follow these steps to get started with plurk.py.
1. Obtain Plurk API Credentials
If you don't have a Plurk app, create one on the App Sign Up page to get your app key and secret.
2. Set Up Environment Variables
Create a .env file in your project's root directory and add your Plurk app's key and secret:
APP_KEY=<your-plurk-app-key>
APP_SECRET=<your-plurk-app-secret>
A .env.example file is provided as a template.
3. Install Dependencies
Install the required libraries, including python-dotenv for managing environment variables:
pip3 install -r requirements.txt
4. Run the Example
The following example demonstrates how to authenticate and access the Plurk API using plurk.py:
import os
from dotenv import load_dotenv
from plurk import Client
load_dotenv()
APP_KEY = os.getenv('APP_KEY')
APP_SECRET = os.getenv('APP_SECRET')
with Client(APP_KEY, APP_SECRET) as client:
# Get app user's access token
request_token = client.get_request_token()
auth_url = client.get_auth_url(request_token)
print('Plurk OAuth authorization URL (open it with browser): ', auth_url)
auth_code = input('Please input the authorization code retrieved from authorization URL: ')
client.fetch_access_token(request_token, auth_code)
# Access Plurk API
user_data = client.users.me()
print('Display name: ', user_data.display_name)
print('Plurks created: ', user_data.plurks_count)
For an asynchronous example, check the async example.
Development
git clone git@github.com:shc261392/plurk.py.git
cd plurk.py
make install
make install will create a virtual environment in the .venv folder.
To run the test suite:
make test
Dependencies
plurk.py relies on these excellent libraries:
- Authlib for OAuth, using a forked version.
- httpx for both synchronous and asynchronous HTTP requests.
- pydantic for data models with robust typing and validation.
- python-dotenv for managing environment variables.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plurk_py-0.0.5.tar.gz.
File metadata
- Download URL: plurk_py-0.0.5.tar.gz
- Upload date:
- Size: 34.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59cc2eac1367f802c84d008ec72b3cf7f8bcc8b9c89ec706e67a207e8c1b6ab5
|
|
| MD5 |
486a311dd0f5399b80ee22ddd6f0e103
|
|
| BLAKE2b-256 |
ff4d5e1f6569b213c840dac58df2e7de3523f742a509c4900e296573aa926b4c
|
File details
Details for the file plurk_py-0.0.5-py3-none-any.whl.
File metadata
- Download URL: plurk_py-0.0.5-py3-none-any.whl
- Upload date:
- Size: 46.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8edfbe1a97ff02bd4a324251aa99b073dd1802b9f43d313a353e21669ba79c10
|
|
| MD5 |
ea1c1b45da0fed813858fd47c8e7e24f
|
|
| BLAKE2b-256 |
077a1443133ab5c2996148ab46dcaa269cc08d9fb390500f6519c79705f6d394
|