Skip to main content

An unofficial Plurk API 2.0 SDK for Python 3.8+.

Project description

plurk.py

An modern library of interacting with Plurk API 2.0 for Python 3.8+.

main

Features

  • Access Plurk API with OAuth easily. (Code example)
  • Full sync and async API call support.
  • Support all API endpoints listed in the official API doc.
  • A helper function to subscribe to timeline updates easily. (Code example)

Requirement

  • Python 3.8+

Testing dependencies requires Python 3.8+. The package might still works for Python 3.7 though it is not recommended.

Installation

$ pip3 install plurk.py

Quickstart

See the example below for how to use plurk.py.

Replace the value of APP_KEY and APP_SECRET with your Plurk app's key and secret. If you haven't create a Plurk app yet, visit the App Sign Up page to register your app and retrieve your app key and app secret.

Note that using hardcoded credentials is a bad practice. The script here is only for demonstration purpose, do not use it without modification in production.

from plurk import Client

APP_KEY = '<your-plurk-app-key>'
APP_SECRET = '<your-plurk-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 async example, check here.

Development

$ git clone git@github.com:shc261392/plurk.py.git
$ cd plurk.py
$ make test
$ make install

make install will automatically create a virtualenv in the current folder named .venv.

To run test suite:

$ make test

Dependencies

plurk.py depends on the following brilliant works:

  • Authlib for OAuth. The project uses the forked version.
  • httpx, a solid library for both sync and async HTTP requests
  • pydantic for building data models with great typing and validation support.

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

plurk.py-0.0.3.tar.gz (35.0 kB view details)

Uploaded Source

Built Distribution

plurk.py-0.0.3-py3-none-any.whl (46.6 kB view details)

Uploaded Python 3

File details

Details for the file plurk.py-0.0.3.tar.gz.

File metadata

  • Download URL: plurk.py-0.0.3.tar.gz
  • Upload date:
  • Size: 35.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for plurk.py-0.0.3.tar.gz
Algorithm Hash digest
SHA256 6817e57fa5096fe3b4f213f352c147aaf8004b90cd032f8d0555da0dc6a3e5b3
MD5 4a2c328422fe586a43f839e23045cb13
BLAKE2b-256 bcfafc2a3bbcd21e712a5dd003bb11f16a1ca2453a4f8066e6298b6947a891cc

See more details on using hashes here.

File details

Details for the file plurk.py-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: plurk.py-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 46.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for plurk.py-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a0aedcf454e9b0b431335ce8da0b147e3951f9bfc65e6e72d843c9ffa2e3b89e
MD5 0a6970cedef9b0dcac4c420f520f1ec2
BLAKE2b-256 713abad954a6d6c3239f483e10385b39b5f09503cb9a5852ded7c3d955134304

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