Python client for the pCloud API.
Project description
pcloud-python-sdk
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, location="EU")
print("Go to:", flow.start(state="xyz"))
code = input("Paste code: ").strip()
token = flow.finish(code)
# 2) Use the client
pc = PCloud(access_token=token.access_token)
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 clientpcloud.PCloudOAuth2Flow/pcloud.PCloudOAuth2FlowNoRedirect: OAuth helpersclient.files.*:list_folder,create_folder,delete_filefiles_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.Zand let GitHub Actions publish (see.github/workflows/release.yml).
License
MIT
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
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 pcloud_python_sdk-1.0.2.tar.gz.
File metadata
- Download URL: pcloud_python_sdk-1.0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51b61366e320acd5a43e57c3660d93635b004e4708d124bc3ff094bf6e780a67
|
|
| MD5 |
27aa51a717bd32f7f9d08ff220e9f51c
|
|
| BLAKE2b-256 |
55f53413611806ff6e11e7bc23327aded1cf6083065d206fe6e7adcc66dbbe5b
|
File details
Details for the file pcloud_python_sdk-1.0.2-py3-none-any.whl.
File metadata
- Download URL: pcloud_python_sdk-1.0.2-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93bd8ac0acb053b583428cd62741c5a85cd3a18adc8aedf1fc829e2e1745645c
|
|
| MD5 |
6d48d44671a75945e7fd527030061dde
|
|
| BLAKE2b-256 |
060920fb7cb0cc3a4b15b06dac9a33b5e508eca5d1c5520aa83ee88edd78c866
|