Skip to main content

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 is forked from 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 through 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 upload file", "test.zip"))
# "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("Test upload files", ["file1.zip", "file2.zip"]))
# "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("<my-very-personal-api-key>")

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

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("<my-very-personal-api-key>")

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

Testing authentication

If you need to test authentication validity

from wetransfer import TransferApi

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

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 works perfectly without providing it.

from wetransfer import TransferApi

x = TransferApi("<my-very-personal-api-key>", 
                user_identifier="81940232-9857-4cf7-b685-7a404faf5205")

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

Unit tests

The package has a number of tests. You can run the tests by running the command python setup.py test. Please make sure you have defined the environment variable WE_API_KEY, otherwise all tests will fail. See 'Usage' above to see how you can obtain a key. You can set the key in a shell like so:

export WE_API_KEY=WvMlogNaWLubua6S5iuA5tRk6ZZDqwh6yaxOpGNa

This is an invalid key, so make sure to use your own key.

Please note that the tests actually upload files, and this may take a while (depending on your internet connection). Also, running the tests counts toward your API key usage, so bear this in mind.

Metadata

Release files for py3-wetransfer 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py3-wetransfer 1.0.3
File Size Uploaded
py3-wetransfer-1.0.3.tar.gz 8.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py3-wetransfer 1.0.3
File Interpreter ABI Platform
py3_wetransfer-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 23.4 kB

Release files / py3-wetransfer-1.0.3.tar.gz

Download URL py3-wetransfer-1.0.3.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1791b249612c64aceec8e2122eed16eb34de3b5f59dcf7d6f0b3627dc3c66e30
BLAKE2b-256 checksum
How to use checksums
81a303f13f9793a058cdb3768cff55eb5f23bbf5fedc64658479d6894bc50c6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

Release files / py3_wetransfer-1.0.3-py3-none-any.whl

Download URL py3_wetransfer-1.0.3-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4123b5777c5fc4c3e25ef2929da479196811dfb401a7cfd18f357aeceb8e705e
BLAKE2b-256 checksum
How to use checksums
a4e07649b265d7525c42cf4748d88bf33c38e78843449d6af508caf6d3d4c540
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

3 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page