Skip to main content

Python client for the pCloud API.

Project description

pcloud-python-sdk

PyPI version CI

Dropbox-style Python SDK for the pCloud API.

Install

pip install pcloud-python-sdk

Quickstart

from pcloud import PCloud, PCloudOAuth2Flow

# 1) OAuth flow (web) — paste the code back
flow = PCloudOAuth2Flow(app_key, app_secret,
                        redirect_uri=None,  # EXACT match
                        location="EU")

auth_url = flow.start(state="xyz")
print("Open:", auth_url)  # sanity check the redirect_uri value shown

code = input("Paste the code from the URL bar: ").strip()
tok = flow.finish(code)

pc = PCloud(access_token=tok.access_token, location="EU")
print(pc.files.list_folder(folderid=0))

Upload with progress

from pcloud import PCloud
pc = PCloud(access_token="...")

def on_progress(done, total):
    if total:
        pct = 100.0 * done / total
        print(f"Uploaded {done}/{total} bytes ({pct:.1f}%)")
    else:
        print(f"Uploaded {done} bytes")

pc.files.files_upload("local.jpg", folderid=0, on_progress=on_progress)

Download with progress

from pcloud import PCloud
pc = PCloud(access_token="...")

def on_progress(done, total):
    if total:
        pct = 100.0 * done / total
        print(f"Downloaded {done}/{total} bytes ({pct:.1f}%)")
    else:
        print(f"Downloaded {done} bytes")

pc.files.files_download(fileid=12345, dest_path="./local.jpg", on_progress=on_progress)

API surface

  • pcloud.PCloud: top-level client
  • pcloud.PCloudOAuth2Flow / pcloud.PCloudOAuth2FlowNoRedirect: OAuth helpers
  • client.files.*:
    • list_folder, create_folder, delete_file
    • files_upload, files_download, get_file_link

This mirrors the ergonomics of the Dropbox Python SDK while using pCloud endpoints under the hood.

Development

python -m pip install -U pip
pip install -e .
pip install pytest ruff mypy
pytest -q

Releasing

  • Create a PyPI project & token.
  • Locally:
    python -m pip install -U build twine
    python -m build
    twine check dist/*
    twine upload dist/*
    
  • Or tag vX.Y.Z and let GitHub Actions publish (see .github/workflows/release.yml).

License

MIT

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

pcloud_python_sdk-1.0.3.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pcloud_python_sdk-1.0.3-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file pcloud_python_sdk-1.0.3.tar.gz.

File metadata

  • Download URL: pcloud_python_sdk-1.0.3.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.6

File hashes

Hashes for pcloud_python_sdk-1.0.3.tar.gz
Algorithm Hash digest
SHA256 454d29d1900069cf40e29326107d469dbbaf7894c4c2a7b5bcabaac00b6d2f45
MD5 076e7f08f4338aed0ea03f63ac74da57
BLAKE2b-256 49e64177a020130ca99f4bffdc4ba302e9d2f647cdd82a413ff237d900aee3a9

See more details on using hashes here.

File details

Details for the file pcloud_python_sdk-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pcloud_python_sdk-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 497c057dc9221a67431a9531a2afb747735b54efe33cfccf1e0b597616745c3f
MD5 ac566fa1bf64756394120031d4412f1c
BLAKE2b-256 31a17984871b5331ab69c742e1c94c2bc5a462eb30a5cf4a6232c285580bb5e6

See more details on using hashes here.

Supported by

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