python-tiktok
A simple Python wrapper around for Tiktok API :sparkles: :cake: :sparkles:.
Introduction
This library provides a service to easily use TikTok official apis.
For now, include follows apis:
Installing
You can install this library easily by pypi:
$ pip install python-tiktok
More installing detail see Installation docs
Using
You can see more usage detail at usage docs
Business Account
Version Tips :
API for Business Version 1.3 is now live! visit here for more details.
Now this library set default version to v1.3.
And v1.2 will be deprecated on August 15, 2023.
If you have account access token, you can initialize api instance by it.
>>> from pytiktok import BusinessAccountApi
>>> business_api = BusinessAccountApi(access_token="Your Access Token")
Or you can let account to give permission by OAuth flow. See business authorization docs
Now you can get account’s data.
Get account profile:
>>> business_api.get_account_data(business_id="Business ID", return_json=True)
>>> # {'code':0,'message':'OK','request_id':'2022070106561301000400402500400500600301500A52386','data':{'display_name':'kiki','profile_image':'https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/accb4aeac4ec812e2bdc45ce1da1ed39~c5_168x168.jpeg?x-expires=1656828000&x-signature=MmXPWeImP%2BRGBwAOqN3wjPpDiZE%3D'}}
If you set function parameter return_json to True, will return the json dict data. Otherwise will return a dataclass object representing the response.
Get account videos:
>>> business_api.get_account_videos(business_id="Business ID", return_json=True)
>>> # {'code':0,'message':'OK','request_id':'20220701071724010004003007735002053068B3FD9','data':{'videos':[{'item_id':'7108684822863760646'},{'item_id':'7109064881462152453'}],'has_more':False,'cursor':0}}
Kit Api
If you have user access token, you can initialize api instance by it.
>>> from pytiktok import KitApi
>>> kit_api = KitApi(access_token="Your Access Token")
Or you can let user to give permission by OAuth flow. See kit authorization docs
Now you can get account’s data.
Get user info:
>>> kit_api.get_user_info(open_id="User Openid", return_json=True)
>>> # {'data':{'user':{'open_id':'open_id','union_id':'union_id','avatar_url':'https://p16-sign-sg.tiktokcdn.com/tiktok-obj/7046311066329939970~c5_168x168.jpeg?x-expires=1656907200&x-signature=w4%2FugSm2IOdma6p0D9V%2FZneIlPU%3D','display_name':'ki'}},'error':{'code':0,'message':''}}
Get user videos:
>>> kit_api.get_user_videos(open_id="_000Hqnyyz5UYe39YWBZwFnaQGfyaoh3s4IY", return_json=True)
>>> # {'data':{'videos':[{'create_time':1654670085,'share_url':'https://www.tiktok.com/@klein_kunkun/video/7106753891953347842?utm_campaign=tt4d_open_api&utm_source=aw46lwwtsqjeapig','duration':5,'id':'7106753891953347842'},{'create_time':1654658105,'share_url':'https://www.tiktok.com/@klein_kunkun/video/7106702437926407426?utm_campaign=tt4d_open_api&utm_source=aw46lwwtsqjeapig','duration':6,'id':'7106702437926407426'}],'cursor':1654658105000,'has_more':False},'error':{'code':0,'message':''}}
Metadata
Release files for python-tiktok 0.1.12
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 |
|---|---|---|---|---|
| python_tiktok-0.1.12.tar.gz | 15.5 kB | Without provenance | Details for python_tiktok-0.1.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_tiktok-0.1.12-py3-none-any.whl | Python 3 | none | any | Details for python_tiktok-0.1.12-py3-none-any.whl |
Total release size: 32.2 kB
Release files / python_tiktok-0.1.12.tar.gz
| Download URL | python_tiktok-0.1.12.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f535ec16df6a47566443a7806b00e434718124e040cbd55c5213ba18f2fc778
|
|
BLAKE2b-256 checksum How to use checksums |
8a78c417eefc90a1acdb70a76a7c4f6a31b197a28f69a8984ef01f195f11a3fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.0 Linux/6.17.0-1015-azure
|
Release files / python_tiktok-0.1.12-py3-none-any.whl
| Download URL | python_tiktok-0.1.12-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f3a5681998e694b6784f497929e6ba255a1e6d587ff27c0645c00f5cd669c4fd
|
|
BLAKE2b-256 checksum How to use checksums |
fce166344a92ddfbafc9f06386706010dda9c82a69fc5ed16651a7c46496cb0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.0 Linux/6.17.0-1015-azure
|
Security for python-tiktok 0.1.12
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.