• home
  • about
  • 全ての投稿
  • ソフトウェア・ハードウェアの設定のまとめ
  • 分析関連のまとめ
  • ヘルスケア関連のまとめ
  • 生涯学習関連のまとめ

tikapi

date: 2022-12-05 excerpt: tikapiの概要と使い方

tag: saasapitiktok


tikapiの概要と使い方

概要

  • unofficalなTikTok API
  • お金を払うことで本来取得できないデータが取得可能になるtikapi.ioというサービスを運営している?
    • クレジットカードを登録するのは不安なので、プリペイドのvisaカードなどで支払うことができる
    • bytebance社のデータ利用ポリシーに準拠しているかは要確認

インストール

$ python3 -m pip install tikapi

具体例

プロフィールの取得

from tikapi import TikAPI, ValidationException, ResponseException
import pprint
pp = pprint.PrettyPrinter(indent=2, width=120, depth=6)

api = TikAPI("<api-key>")

try:
    response = api.public.check(
        username="_m12ki"
    )
    pp.pprint(response.json())
except ValidationException as e:
    print(e, e.field)

except ResponseException as e:
    print(e, e.response.status_code)

フィードの取得

from tikapi import TikAPI, ValidationException, ResponseException
import pprint
pp = pprint.PrettyPrinter(indent=2, width=120, depth=6)

api = TikAPI("<api-key>")

try:
    response = api.public.posts(
        secUid="MS4wLjABAAAA7CW0_yn7Ek8eqimjEx3fJdgctLBa5kYiYFEckLvVTe-CwEJ2MuLV-kWRq5mD0Sqw" # userごとの固有値(profileから取得できる)
    )
    pp.pprint(response.json())
    while(response):
        cursor = response.json().get('cursor')
        pp.pprint(response.json())
        response = response.next_items()
except ValidationException as e:
    print(e, e.field)

except ResponseException as e:
    print(e, e.response.status_code)

参考

  • A full-fledged TikTok™ unofficial API


saasapitiktok Share Tweet