Package: transip-stack-api
TransIP STACK APIUnofficial wrapper for the TransIP STACK API, written in Python 3DeprecationUnfortunately due toa decision over at TransIPgoing 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.InstallationTo install the library, simply install it using pip:$ pip install transip-stack-apiFor development installations$ pip install -e .[dev]UsageTo use the project, simply import the library into your project like so:fromtransip_stackimportStack,StackExceptionwithStack(username="foo",password="bar",hostname="stack.example.com")asstack:try:url=stack.upload("local-foo.txt",remote="remote-foo.txt").share()print("[+] You can download remote-foo.txt at:{}".format(url))exceptStackExceptionase: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 progressExamplesfromioimportBytesIOfromtransip_stackimportStack,StackExceptionwithStack(username="foo",password="bar",hostname="stack.example.com")asstack:forfileinstack.files:print(file.name)forfileinstack.ls("foo"):print(file.name)stack.cd("/foo")forfileinstack.files:ifnotfile.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)# -> FalsewithStack(username="someone",password="Pa$$w0rd!",hostname="stack.example.com")asstack: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')exceptStackExceptionase:print(e)# -> "Access denied .."Without context managers:fromtransip_stackimportStackstack=Stack(username="foo",password="bar",hostname="stack.example.com")stack.login()stack.cd("/foo")forfileinstack.files:file.unshare()stack.logout()# ImportantAPI endpointsLogging inPOST/loginQueryNoneBodyusername: strpassword: strResponseSuccess: HTTP 302Failure: HTTP 200Logging outGET/logoutQueryNoneBodyNoneResponseSuccess: HTTP 302Failure:N/AListing filesGET/api/filesQuerydir: str = "/"type: str = "files"public: bool = falseoffset: int = 0limit: int = 1sortBy: str = "default"order: str = "asc"query: str = ""BodyNoneSharing a filePOST/api/files/updateHeadersCSRF-TokenQueryNoneBody (JSON)Array of:action: str = "share"path: str = "<full path to file, see node.path>"active: bool = truetrue: File will be shared and get assigned a tokenfalse: File will no longer be sharedallowWrites: bool = falseupdatePassword: bool = trueSet to true if you want to set a passwordsharePassword: str = ""Required when setting a passwordupdateExpireDate: bool = true*Set to true if you want to set an expiry dateexpireDate: date = ""Required when setting an expiry dateDeleting a filePOST/api/files/updateHeadersCSRF-TokenQueryNoneBody (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 deletionGetting file informationGET/api/pathinfoQuerypath: str = ""BodyNoneMarking a file as favoritedPOST/api/files/updateHeadersCSRF-TokenQueryNoneBody (JSON)Array of:action: str = "favorite"active: boolTrue = FavoritedFalse = Unfavoritedpath: str = "<full path to file, see node.path>"query: str = ""Not sure why this is added, possibly for mass file deletionList usersGET/api/usersBodyNoneQuerypublic: bool = falseoffset: int = 0limit: int = 50query str = ""Delete a userPOST/api/users/updateBody (JSON)Array of:action: str = "delete"user: User*The entire user object you got fromGET /api/usersQueryNoneUpdate a user's propertiesPOST/api/users/updateBody (JSON)Array of:action: str = "update"user: UserQueryNoneHeadersCSRF-TokenFound in/filesin a meta tag with the namecsrf-tokenTypesNode (Dict)fileId: intpath: strmimetype: stretag: strshareToken: strexpirationDate: strhasSharePassword: boolshareTime: intcanUpload: boolfileSize: intisFavorited: boolmtime: intisPreviewable: boolwidth: intheight: intUser (Dict)username: strdisplayName: strquota: intused: intisAdmin: boolisPremium: boollanguage: str