A Python 3 wrapper to use WeTransfer API V2 transfer and board
Project description
WeTransfer V2 Upload wrapper
Built by myself for Python 3.x, because I didn't find such thing already written anywhere else...
Based on current WeTransfer API V2
python > 3.5
We are working to publish the package on Pypi, soon available, and immediatelly available on test.pypi.org:
pip install --index-url https://test.pypi.org/simple/ py3wetransfer
Functional features
-
Transfer API https://wetransfer.github.io/wt-api-docs/index.html#transfer-api
-
Board API https://wetransfer.github.io/wt-api-docs/index.html#board-api
Usage
Before starting, make sure you have an API key acquired from Developers Portal.
To initialize the client, you need to use your own api key.
Transfer
upload_file
Simply send your file
from py3wetransfer import Py3WeTransfer
x = Py3WeTransfer("<my-very-personal-api-key>")
print( x.upload_file("test.zip", "test upload") )
>> "https://we.tl/t-ajQpdqGxco"
upload_files
Send several files
from py3wetransfer import Py3WeTransfer
x = Py3WeTransfer("<my-very-personal-api-key>")
print( x.upload_files( ["file1.zip", "file2.zip"] , "test upload") )
>> "https://we.tl/t-ajQpdqGxco"
Board
Manage board
from py3wetransfer import Py3WeTransfer
x = Py3WeTransfer("<my-very-personal-api-key>")
[ board_id, board_url ] = x.create_new_board("test board")
print(board_url)
>> "https://we.tl/t-ajQpdqGxco"
# add links
x.add_links_to_board( board_id, [{"url": "https://wetransfer.com/", "title": "WeTransfer"}] )
# add files
x.add_files_to_board( board_id, ["test1.png", "test2.jpg"] )
# retrieve the board object
# https://wetransfer.github.io/wt-api-docs/index.html#retrieve-boards-information
board_object = x.get_board( board_id )
Debug
import logging
from py3wetransfer import Py3WeTransfer
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
py3wetransfer_log = logging.getLogger("py3wetransfer")
py3wetransfer_log.setLevel(logging.DEBUG)
py3wetransfer_log.propagate = True
x = Py3WeTransfer("xA8ZYoVox57QfxX77hjQ2AI7hqO6l9M4tqv8b57c")
print( x.upload_file("test.zip", "test upload") )
...
If you want to see complete http traffic:
import logging
from py3wetransfer import Py3WeTransfer
import http.client as http_client
http_client.HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
py3wetransfer_log = logging.getLogger("py3wetransfer")
py3wetransfer_log.setLevel(logging.DEBUG)
py3wetransfer_log.propagate = True
x = Py3WeTransfer("xA8ZYoVox57QfxX77hjQ2AI7hqO6l9M4tqv8b57c")
print( x.upload_file("test.zip", "test upload") )
...
Testing authentication
If you need to test authentication validity
from py3wetransfer import Py3WeTransfer
x = Py3WeTransfer("xA8ZYoVox57QfxX77hjQ2AI7hqO6l9M4tqv8b57c")
if x.isAuthentified() : print("we are authentified")
Additionnal authentication parameters
WeTransfer asks officially for a valid "domain_user_id"/"user_identifier" in their API documentation, but in practise, it perfectly works without providing it, but you can also provide it if you really want...
from py3wetransfer import Py3WeTransfer
x = Py3WeTransfer( "xA8ZYoVox57QfxX77hjQ2AI7hqO6l9M4tqv8b57c",
user_identifier="81940232-9857-4cf7-b685-7a404faf5205")
print( x.upload_file("test.zip", "test upload") )
>> "https://we.tl/t-ajQpdqGxco"
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
Hashes for py3wetransfer-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac7a477646535a8f6ab2b5d97561c6dde243e392eddc9449c54c6db0d10f712c |
|
MD5 | 4dc240f1c2706baeda896db3088c12dd |
|
BLAKE2b-256 | 46f959d27d8d20028142facad86e45b5cc08ebe6c88ac4ef8f1d7e0d50f259c2 |