Python SDK for PinArkive API v3 – minimal client (upload, pin, remove, users/me, uploads, tokens, status, allocations). See https://pinarkive.com/docs.php
Project description
Pinarkive Python SDK
Minimal Python client for the PinArkive API v3. Upload files, pin by CID, manage tokens, and check status. See pinarkive.com/docs.php.
Version: 3.1.1
Installation
pip install pinarkive-sdk-py
Quick Start
from pinarkive_client import PinarkiveClient, PinarkiveError
# Auth: Bearer token or X-API-Key (default base URL: https://api.pinarkive.com/api/v3)
client = PinarkiveClient(api_key="your-api-key-here")
# Upload a file
result = client.upload_file("document.pdf")
print(result["cid"])
# Or login first
login = client.login("user@example.com", "password")
client = PinarkiveClient(token=login["token"])
# List uploads
data = client.list_uploads(page=1, limit=20)
print(data["uploads"])
Authentication
- API Key:
PinarkiveClient(api_key="...")— sent asX-API-Keyheader. - JWT:
PinarkiveClient(token="...")— sent asAuthorization: Bearer <token>. - Base URL: optional third argument, default
https://api.pinarkive.com/api/v3. - request_source: optional keyword argument. When set to
"web", the client sendsX-Request-Source: webon every Bearer-authenticated request (not when using API Key), so the backend classifies them as WEB in logs instead of JWT. Use this when the SDK runs from a web app.
API Methods (minimal set)
| Method | Description |
|---|---|
health() |
GET /health |
get_plans() |
GET /plans/ |
get_peers() |
GET /peers/ |
login(email, password) |
POST /auth/login |
verify_2fa_login(temporary_token, code) |
POST /auth/2fa/verify-login |
upload_file(path, cluster_id=None, timelock=None) |
POST /files/ |
upload_directory(dir_path, cluster_id=None, timelock=None) |
POST /files/directory |
upload_directory_dag(files_dict, dir_name=None, cluster_id=None, timelock=None) |
POST /files/directory-dag |
pin_cid(cid, original_name=None, custom_name=None, cluster_id=None, timelock=None) |
POST /files/pin/:cid |
remove_file(cid) |
DELETE /files/remove/:cid |
get_me() |
GET /users/me |
list_uploads(page=1, limit=20) |
GET /users/me/uploads |
generate_token(name, label=None, expires_in_days=None, scopes=None, totp_code=None) |
POST /tokens/generate |
list_tokens() |
GET /tokens/list |
revoke_token(name, totp_code=None) |
DELETE /tokens/revoke/:name |
get_status(cid, cluster_id=None) |
GET /status/:cid |
get_allocations(cid, cluster_id=None) |
GET /allocations/:cid |
Optional cluster_id and timelock (ISO 8601, premium) follow the API docs.
Error handling
On HTTP 4xx/5xx the client raises PinarkiveError with:
status_code— HTTP status (400, 401, 403, 404, 409, 413, 429, 500, 503)message— from APImessageorerrorbody— full JSON body.error— API fielderror.code— API fieldcode(e.g.email_not_verified,missing_scope).required— for 403missing_scope: the required scope.retry_after— for 429: seconds until retry (from body orRetry-Afterheader)
try:
client.upload_file("large.bin")
except PinarkiveError as e:
print(e.status_code, e.message, e.code)
Changelog
3.1.0
- Request source:
request_source="web"sendsX-Request-Source: webon Bearer requests. - Scopes & 2FA:
generate_token(..., scopes=..., totp_code=...);revoke_token(name, totp_code=...).verify_2fa_login(temporary_token, code)for login with 2FA. - Errors:
PinarkiveError.required(403 missing_scope),PinarkiveError.retry_after(429).
3.1.1
- Fix:
upload_directory_dagnow sends multipart with repeated field namefiles, with each part’s filename equal to the relative path in the DAG (backend multerupload.array('files')). The previousfiles[i][path]/files[i][content]format is not accepted by the backend.
See also CHANGELOG.md.
3.0.0
- API v3: Base URL is now
https://api.pinarkive.com/api/v3(was/api/v2). v1/v2 are deprecated (410). - Errors: On 4xx/5xx the client raises
PinarkiveErrorwithstatus_code,message,body, and.error/.codefrom the API (no rawResponseon failure). - Minimal surface: Only endpoints documented at pinarkive.com/docs.php: health, plans, peers, login, files (upload, directory, directory-dag, pin, remove), users/me, uploads, tokens (generate with
name/label/expiresInDays), status, allocations. Optionalcluster_idandtimelock(ISO 8601) on upload/pin. - Removed:
rename_file; token optionspermissions,ip_allowlist. Use APIlabelandexpiresInDaysonly. - Pin:
pin_cidnow acceptsoriginal_name,custom_name(replacing the oldfilename). - Return values: Successful calls return decoded JSON (dict); methods that return nothing on success (
remove_file,revoke_token) returnNone.
Upgrading from 2.x
- Change base URL to
/api/v3or rely on the new default. - Replace
result.json()with the direct return value (client returns dicts; on error,PinarkiveErroris raised). - Catch
PinarkiveErrorinstead ofrequests.HTTPErrorand usee.status_code,e.message,e.body. - Use
pin_cid(cid, custom_name=...)instead ofpin_cid(cid, filename=...); addoriginal_nameif needed. - Use
generate_token(name, label=..., expires_in_days=...); droppermissionsandip_allowlist. - Pin to
pinarkive-sdk-py>=3.0.0if you rely on v3 behaviour.
Links
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 pinarkive_sdk_py-3.1.1.tar.gz.
File metadata
- Download URL: pinarkive_sdk_py-3.1.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa153402ff2941f5a92b8c58b44aa67aa919665ad93cfe2552e950c8734382f8
|
|
| MD5 |
1e4ee6afc11096b39e5f41e5b56cef81
|
|
| BLAKE2b-256 |
483c65b704cb07040de074db347f3718575bd4cfdf6da03570541c85885e2af1
|
Provenance
The following attestation bundles were made for pinarkive_sdk_py-3.1.1.tar.gz:
Publisher:
publish.yml on pinarkive/pinarkive-sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pinarkive_sdk_py-3.1.1.tar.gz -
Subject digest:
fa153402ff2941f5a92b8c58b44aa67aa919665ad93cfe2552e950c8734382f8 - Sigstore transparency entry: 1293631894
- Sigstore integration time:
-
Permalink:
pinarkive/pinarkive-sdk-py@b1448bf59c95b8e2d82b6aa70a75c17fb4dc7042 -
Branch / Tag:
refs/tags/v3.1.1 - Owner: https://github.com/pinarkive
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b1448bf59c95b8e2d82b6aa70a75c17fb4dc7042 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pinarkive_sdk_py-3.1.1-py3-none-any.whl.
File metadata
- Download URL: pinarkive_sdk_py-3.1.1-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66728103fefc6236a2c054a2548fa1612b8e32a340d2dece2b02b48c84a73c91
|
|
| MD5 |
63442a6b18caef096a2bf1ac2d63d1cd
|
|
| BLAKE2b-256 |
683657187bcb55a970068c2be97a6e2a0e164ebd2dd763e340e6ecbdc3b659f0
|
Provenance
The following attestation bundles were made for pinarkive_sdk_py-3.1.1-py3-none-any.whl:
Publisher:
publish.yml on pinarkive/pinarkive-sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pinarkive_sdk_py-3.1.1-py3-none-any.whl -
Subject digest:
66728103fefc6236a2c054a2548fa1612b8e32a340d2dece2b02b48c84a73c91 - Sigstore transparency entry: 1293631903
- Sigstore integration time:
-
Permalink:
pinarkive/pinarkive-sdk-py@b1448bf59c95b8e2d82b6aa70a75c17fb4dc7042 -
Branch / Tag:
refs/tags/v3.1.1 - Owner: https://github.com/pinarkive
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b1448bf59c95b8e2d82b6aa70a75c17fb4dc7042 -
Trigger Event:
release
-
Statement type: