Skip to main content

A Python 3 wrapper to use WeTransfer API V2 transfer and board

Project description

WeTransfer V2 Upload wrapper

This module allows you to use WeTransfer services directly, from python 3.x.

It is based on current WeTransfer API V2: https://developers.wetransfer.com/documentation

This project was originally a fork of the py3wetransfer repository that was maintained by Francois Liot. You can still find it here. It seems, however, that it is no longer maintained.

Installation

Install though Pypi:

pip install py3-wetransfer

Functional features

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 wetransfer import TransferApi

x = TransferApi("<my-very-personal-api-key>")

print( x.upload_file("test.zip", "test upload") )
# "https://we.tl/t-ajQpdqGxco"

upload_files

Send several files

from wetransfer import TransferApi

x = TransferApi("<my-very-personal-api-key>")

print( x.upload_files( ["file1.zip", "file2.zip"] , "test upload") )
# "https://we.tl/t-ajQpdqGxco"

Board

Manage board

from wetransfer import BoardApi

x = BoardApi("<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 wetransfer import TransferApi

logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
py3wetransfer_log = logging.getLogger('wetransfer')
py3wetransfer_log.setLevel(logging.DEBUG)
py3wetransfer_log.propagate = True

x = TransferApi("xA8ZYoVox57QfxX77hjQ2AI7hqO6l9M4tqv8b57c")

print( x.upload_file("test.zip", "test upload") )

If you want to see complete http traffic:

import logging
from wetransfer import TransferApi

import http.client as http_client
http_client.HTTPConnection.debuglevel = 1

logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
py3wetransfer_log = logging.getLogger('wetransfer')
py3wetransfer_log.setLevel(logging.DEBUG)
py3wetransfer_log.propagate = True

x = TransferApi("xA8ZYoVox57QfxX77hjQ2AI7hqO6l9M4tqv8b57c")

print( x.upload_file("test.zip", "test upload") )

Testing authentication

If you need to test authentication validity

from wetransfer import TransferApi

x = TransferApi("xA8ZYoVox57QfxX77hjQ2AI7hqO6l9M4tqv8b57c")

if x.is_authenticated() : print("we are authenticated")

Additional 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 wetransfer import TransferApi

x = TransferApi( "xA8ZYoVox57QfxX77hjQ2AI7hqO6l9M4tqv8b57c", 
                     user_identifier="81940232-9857-4cf7-b685-7a404faf5205")

print( x.upload_file("test.zip", "test upload") )
# "https://we.tl/t-ajQpdqGxco"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py3-wetransfer-0.1.0.tar.gz (9.3 kB view hashes)

Uploaded Source

Built Distribution

py3_wetransfer-0.1.0-py3-none-any.whl (15.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page