HohnerJulian / ResearchTikPy

Python API wrapper for the TikTok Research API
MIT License
18 stars 3 forks source link

Use the /query endpoint more flexibly #3

Closed tomasruizt closed 4 months ago

tomasruizt commented 4 months ago

Hi! thank you for the awesome package :) We are building on top of it 🚀

I would like to call the endpoint

https://open.tiktokapis.com/v2/research/video/query/

With a custom query. At the moment the only way to use the endpoint with the package is to use rtk.get_videos_hashtag(). However, I'm interested not only in hashtags, but also in keywords for the search: "field_name":"keyword", like in the docs.

One option would be to just add a new optional parameter keywords: list[str] to rtk.get_videos_hashtag(). However, this still makes hashtags mandatory, even though they are not strictly mandatory in the research API.

The other option which I find better is to add a new function rtk.get_videos_query() which takes a paramter query: dict.

def get_videos_hashtag(hashtags, access_token, start_date, end_date, ...):
    query = ...
    return get_videos_query(...)

def get_videos_query(query: dict, ...)
    # query the tiktok API, and return results
    ...

I'm happy to contribute either of those in a pull-request + a corresponding test case.

What do you think?

HohnerJulian commented 4 months ago

Sounds good! :) You can make a pull request if you want to; I'm inviting you as a collaborator.