Welcome to the official GitHub repository for the SPARTA TikTok API, a powerful Python implementation to interact with TikTok's Research API in a robust and efficient manner.
- Methods for gathering video metadata, users and more.
- Asynchronous API calls support.
- Efficient error handling.
- Comprehensive documentation with usage examples.
We recommend using Poetry for managing the project dependencies. If you don't have Poetry installed, check their official documentation for guidance.
To install the SPARTA TikTok API via Poetry:
poetry add sparta-tiktokapi
or to install it via pip:
pip3 install sparta-tiktokapi
Here's a simple example to get you started:
from datetime import date
from sparta.tiktokapi.access import create_bearer_token
from sparta.tiktokapi.videos.videos import query_videos
client_key = "xxxxxxxxxxx"
client_secret = "xxxxxxxxxxx"
bearer_token = create_bearer_token(client_key, client_secret)
query = {"or": [{"operation": "IN", "field_name": "username", "field_values": ["@tiktok"]}]}
start = date(2023, 1, 1)
end = date(2023, 1, 31)
async for video in query_videos(bearer_token, query, start, end, max_count=100):
print(video)
For in-depth methods and examples, consult our official documentation.
Clone the Repo:
git clone https://github.com/UnibwSparta/tiktokapi.git
cd tiktokapi
Install Dependencies:
poetry install
Submit Your Changes: Make your improvements and propose a Pull Request!
Tests are powered by pytest. Execute tests with:
poetry run pytest tests/
Issues? Feedback? Use the GitHub issue tracker.
MIT License. View LICENSE for details.
SPARTA is an interdisciplinary research project at the UniBw M. The Chair of Political Science is responsible for managing the project. The project is funded by dtec.bw (Digitalization and Technology Research Center of the Bundeswehr). dtec.bw is funded by the European Union - NextGenerationEU.