TransIP STACK API
Unofficial wrapper for the TransIP STACK API, written in Python 3
Deprecation
Unfortunately due to a decision over at TransIP going forward STACK will no longer be free and all free accounts will be removed by February 12th 2021. As a result, I have decided to officially end support of this library as I personally believe there are far better quality cloud storage providers for the same price.
Installation
To install the library, simply install it using pip:
$ pip install transip-stack-api
For development installations
$ pip install -e .[dev]
Usage
To use the project, simply import the library into your project like so:
from transip_stack import Stack, StackException
with Stack(username="foo", password="bar", hostname="stack.example.com") as stack:
try:
url = stack.upload("local-foo.txt", remote="remote-foo.txt").share()
print("[+] You can download remote-foo.txt at: {}".format(url))
except StackException as e:
print("[!] Error: {}".format(e))
The package also ships with a command line interface to easily upload files in your current working directory to stack. Configuration is done via environment variables:
$ export STACK_USERNAME=...
$ export STACK_PASSWORD=...
$ export STACK_HOSTNAME=...
$ export STACK_DIRECTORY=...
Then simply use the tool:
$ stack upload .
Note that the command line interface is a work in progress
Examples
from io import BytesIO
from transip_stack import Stack, StackException
with Stack(username="foo", password="bar", hostname="stack.example.com") as stack:
for file in stack.files:
print(file.name)
for file in stack.ls("foo"):
print(file.name)
stack.cd("/foo")
for file in stack.files:
if not file.is_shared:
file.share()
print(file.share_url)
user = stack.user("admin")
user.name = "John Doe"
user.save()
user = stack.user_or_create_new(
name="Someone Else",
username="someone",
password="Pa$$w0rd!",
disk_quota=5 * 1000 * 1000)
print(user.is_admin) # -> False
with Stack(username="someone", password="Pa$$w0rd!", hostname="stack.example.com") as stack:
stack.upload("foo.txt")
stack.download("foo.txt", "example.txt")
buff = BytesIO()
stack.download_into("foo.txt", buffer=buff)
print(buff.getvalue().decode())
try:
user = stack.user('admin')
except StackException as e:
print(e) # -> "Access denied .."
Without context managers:
from transip_stack import Stack
stack = Stack(username="foo", password="bar", hostname="stack.example.com")
stack.login()
stack.cd("/foo")
for file in stack.files:
file.unshare()
stack.logout() # Important
API endpoints
Logging in
- POST
/login- Query
- None
- Body
- username: str
- password: str
- Response
- Success: HTTP 302
- Failure: HTTP 200
- Query
Logging out
- GET
/logout- Query
- None
- Body
- None
- Response
- Success: HTTP 302
- Failure: N/A
- Query
Listing files
- GET
/api/files- Query
- dir: str = "/"
- type: str = "files"
- public: bool = false
- offset: int = 0
- limit: int = 1
- sortBy: str = "default"
- order: str = "asc"
- query: str = ""
- Body
- None
- Query
Sharing a file
- POST
/api/files/update- Headers
- CSRF-Token
- Query
- None
- Body (JSON)
- Array of:
- action: str = "share"
- path: str = "<full path to file, see node.path>"
- active: bool = true
- true: File will be shared and get assigned a token
- false: File will no longer be shared
- allowWrites: bool = false
- updatePassword: bool = true
- Set to true if you want to set a password
- sharePassword: str = ""
- Required when setting a password
- updateExpireDate: bool = true
- *Set to true if you want to set an expiry date
- expireDate: date = ""
- Required when setting an expiry date
- Array of:
- Headers
Deleting a file
- POST
/api/files/update - Headers
- CSRF-Token
- Query
- None
- Body (JSON)
- Array of:
- action: str = "delete"
- path: str = "<full path to file, see node.path>"
- query: str = ""
- Not sure why this is added, possibly for mass file deletion
- Array of:
Getting file information
- GET
/api/pathinfo- Query
- path: str = ""
- Body
- None
- Query
Marking a file as favorited
- POST
/api/files/update - Headers
- CSRF-Token
- Query
- None
- Body (JSON)
- Array of:
- action: str = "favorite"
- active: bool
- True = Favorited
- False = Unfavorited
- path: str = "<full path to file, see node.path>"
- query: str = ""
- Not sure why this is added, possibly for mass file deletion
- Array of:
List users
- GET
/api/users- Body
- None
- Query
- public: bool = false
- offset: int = 0
- limit: int = 50
- query str = ""
- Body
Delete a user
- POST
/api/users/update- Body (JSON)
- Array of:
- action: str = "delete"
- user: User
- *The entire user object you got from
GET /api/users
- *The entire user object you got from
- Array of:
- Query
- None
- Body (JSON)
Update a user's properties
- POST
/api/users/update- Body (JSON)
- Array of:
- action: str = "update"
- user: User
- Array of:
- Query
- None
- Body (JSON)
Headers
- CSRF-Token
- Found in
/filesin a meta tag with the namecsrf-token
- Found in
Types
-
Node (Dict)
- fileId: int
- path: str
- mimetype: str
- etag: str
- shareToken: str
- expirationDate: str
- hasSharePassword: bool
- shareTime: int
- canUpload: bool
- fileSize: int
- isFavorited: bool
- mtime: int
- isPreviewable: bool
- width: int
- height: int
-
User (Dict)
- username: str
- displayName: str
- quota: int
- used: int
- isAdmin: bool
- isPremium: bool
- language: str
Metadata
Release files for transip-stack-api 1.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| transip-stack-api-1.3.3.tar.gz | 16.1 kB | Without provenance | Details for transip-stack-api-1.3.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| transip_stack_api-1.3.3-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for transip_stack_api-1.3.3-py2.py3-none-any.whl |
Total release size: 31.5 kB
Release files / transip-stack-api-1.3.3.tar.gz
| Download URL | transip-stack-api-1.3.3.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
74d340de880e8d1e93cf26a6cebf9e5a42c981b7fe20983302e7b6487819f40f
|
|
BLAKE2b-256 checksum How to use checksums |
b88617998add80503427fe3c52ba71be76bc7365c9cc7bd68ba683905143f3c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.2
|
Release files / transip_stack_api-1.3.3-py2.py3-none-any.whl
| Download URL | transip_stack_api-1.3.3-py2.py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
96d5ace6c9846662a07e795a979d4aad474aef4dc9ab9a8147ace7e5e39093ff
|
|
BLAKE2b-256 checksum How to use checksums |
84fbc9bffc47aeaef3b3942dccb915e93ff1129ed6af875a803b1a881cee5c63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.2
|
Security for transip-stack-api 1.3.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.