{"id":13672924,"url":"https://github.com/szdc/tiktok-api","last_synced_at":"2025-04-28T04:30:33.675Z","repository":{"id":37734811,"uuid":"135707585","full_name":"szdc/tiktok-api","owner":"szdc","description":"Unofficial API wrapper for TikTok","archived":true,"fork":false,"pushed_at":"2021-09-01T06:36:16.000Z","size":290,"stargazers_count":1282,"open_issues_count":0,"forks_count":280,"subscribers_count":69,"default_branch":"master","last_synced_at":"2025-04-14T03:06:40.479Z","etag":null,"topics":["lively","musically","tiktok"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/szdc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-01T11:05:56.000Z","updated_at":"2025-04-08T10:11:33.000Z","dependencies_parsed_at":"2022-07-12T15:18:16.570Z","dependency_job_id":null,"html_url":"https://github.com/szdc/tiktok-api","commit_stats":null,"previous_names":["szdc/musically-api"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szdc%2Ftiktok-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szdc%2Ftiktok-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szdc%2Ftiktok-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szdc%2Ftiktok-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/szdc","download_url":"https://codeload.github.com/szdc/tiktok-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250735431,"owners_count":21478606,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lively","musically","tiktok"],"created_at":"2024-08-02T09:01:57.668Z","updated_at":"2025-04-28T04:30:33.250Z","avatar_url":"https://github.com/szdc.png","language":"TypeScript","readme":"# Unofficial TikTok/Musical.ly API\n\n\u003e This project is no longer maintained.\n\n---\n\n\u003c!-- markdownlint-disable MD013 --\u003e\n[![npm version](https://img.shields.io/npm/v/tiktok-api.svg?style=flat)](https://www.npmjs.com/package/tiktok-api) [![Coverage Status](https://img.shields.io/coveralls/szdc/tiktok-api/master.svg?style=flat)](https://coveralls.io/github/szdc/tiktok-api?branch=master) [![Build Status](https://travis-ci.com/szdc/tiktok-api.svg?branch=master)](https://travis-ci.com/szdc/tiktok-api) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/szdc/tiktok-api/issues) ![Supported TikTok version](https://img.shields.io/badge/TikTok-9.1.0-blue.svg)\n\u003c!-- markdownlint-enable MD013 --\u003e\n\nA reverse-engineered implementation of the [TikTok](https://www.tiktok.com/) (previously musical.ly) app's API.\n\n## Installation\n\n```bash\nnpm i tiktok-api\n```\n\n## Usage\n\n### Creating an instance\n\n```js\nimport TikTokAPI, { getRequestParams } from 'tiktok-api';\n\n// Required - a method that signs the URL with anti-spam parameters\n// You must provide an implementation yourself to successfully make\n// most requests with this library.\nconst signURL = async (url, ts, deviceId) =\u003e {\n  const as = 'anti-spam parameter 1';\n  const cp = 'anti-spam parameter 2'\n  const mas = 'anti-spam parameter 3';\n  return `${url}\u0026as=${as}\u0026cp=${cp}\u0026mas=${mas}`;\n}\n\n// Required - device parameters\n// You need to source these using a man-in-the-middle proxy such as mitmproxy,\n// CharlesProxy or PacketCapture (Android)\nconst params = getRequestParams({\n  device_id: '\u003cdevice_id\u003e',\n  fp: '\u003cdevice_fingerprint\u003e',\n  iid: '\u003cinstall_id\u003e',\n  openudid: '\u003cdevice_open_udid\u003e',\n});\n\nconst api = new TikTokAPI(params, { signURL });\n\n// You are now able to make successful requests\n\n```\n\n### Instance methods\n\n* [.loginWithEmail(email, password)](#loginwithemailemail-password)\n* [.loginWithUsername(username, password)](#loginwithusernameusername-password)\n* [.getUser(id)](#getuserid)\n* [.searchUsers(params)](#searchusersparams)\n* [.getQRCode(id, [schemaType])](#getqrcodeid-schematype)\n* [.getPost(id)](#getpostid)\n* [.listPosts(params)](#listpostsparams)\n* [.listFollowers(params)](#listfollowersparams)\n* [.listFollowing(params)](#listfollowingparams)\n* [.follow(id)](#followid)\n* [.unfollow(id)](#unfollowid)\n* [.listReceivedFollowRequests(params)](#listreceivedfollowrequestsparams)\n* [.approveFollowRequest(id)](#approvefollowrequestid)\n* [.rejectFollowRequest(id)](#rejectfollowrequestid)\n* [.likePost(id)](#likepostid)\n* [.unlikePost(id)](#unlikepostid)\n* [.listComments(params)](#listcommentsparams)\n* [.postComment(postId, text, [tags])](#postcommentpostid-text-tags)\n* [.listCategories(params)](#listcategoriesparams)\n* [.searchHashtags(params)](#searchhashtagsparams)\n* [.listPostsInHashtag(params)](#listpostsinhashtagparams)\n* [.listForYouFeed([params])](#listforyoufeedparams)\n* [.listFollowingFeed([params])](#listfollowingfeedparams)\n* [.getSticker(id)](#getstickerid)\n* [.getStickers([ids])](#getstickersids)\n* [.listPostsBySticker(params)](#listpostsbystickerparams)\n* [.joinLiveStream(id)](#joinlivestreamid)\n* [.leaveLiveStream(id)](#leavelivestreamid)\n* [.canStartLiveStream()](#canstartlivestream)\n* [.startLiveStream(title, [contactsAuthorized])](#startlivestreamtitle-contactsauthorized)\n* [.endLiveStream(roomId, streamId)](#endlivestreamroomid-streamid)\n* [.createLiveStreamRoom(title, [contactsAuthorized])](#createlivestreamroomtitle-contactsauthorized)\n* [.updateLiveStreamStatus(params)](#updatelivestreamstatusparams)\n\n#### .loginWithEmail(email, password)\n\nAuthenticates you with the API and stores your session data in a cookie jar.\nSubsequent requests will include these cookies.\n\n```javascript\napi.loginWithEmail('\u003cemail\u003e', '\u003cpassword\u003e')\n  .then(res =\u003e console.log(res.data))\n  .catch(console.log)\n\n// Outputs:\n// { email: '\u003cemail\u003e', session_key: '123456', user_id: '123456', ... }\n\n```\n\nSee the [login types](src/types/login.d.ts) for the response data.\n\n#### .loginWithUsername(username, password)\n\nAuthenticates you with the API and stores your session data in a cookie jar.\nSubsequent requests will include these cookies.\n\n```javascript\napi.loginWithUsername('\u003cusername\u003e', '\u003cpassword\u003e')\n  .then(res =\u003e console.log(res.data))\n  .catch(console.log)\n\n// Outputs:\n// { username: '\u003cemail\u003e', session_key: '123456', user_id: '123456', ... }\n\n```\n\nSee the [login types](src/types/login.d.ts) for the response data.\n\n#### .getUser(id)\n\nGets a user's profile.\n\n```javascript\napi.getUser('\u003cuser_id\u003e')\n  .then(res =\u003e console.log(res.data.user))\n  .catch(console.log);\n\n// Outputs:\n// { aweme_count: 1000, nickname: 'example', unique_id: 'musername', ... }\n\n```\n\nSee the [user types](src/types/user.d.ts) for the response data.\n\n#### .searchUsers(params)\n\nSearches for users.\n\n```javascript\napi.searchUsers({\n  keyword: 'example',\n  count: 10,\n  cursor: 0,\n})\n  .then(res =\u003e console.log(res.data.user_list))\n  .catch(console.log);\n\n// Outputs:\n// [{ user_info: {...}, position: [], uniqposition: [] }, ...]\n\n```\n\nSee the [search types](src/types/search.d.ts) for the complete request/response objects.\n\n#### .getQRCode(id, [schemaType])\n\nGets the QR code for a user.\n\n```javascript\napi.getQRCode('\u003cuser_id\u003e')\n  .then(res =\u003e console.log(res.data.qrcode_url.url_list[0]))\n  .catch(console.log);\n\n// Outputs:\n// 'http://p16.muscdn.com/img/musically-qrcode/1111111111111111111~c5_720x720.image'\n\n```\n\nSee the [QR code types](src/types/qr-code.d.ts) for the complete request/response objects.\n\n#### .getPost(id)\n\nGets a post.\n\n```javascript\napi.getPost('\u003cuser_id\u003e')\n  .then(res =\u003e console.log(res.data.aweme_detail))\n  .catch(console.log);\n\n// Outputs:\n// { author: {...}, aweme_id: '999', desc: 'description', music: {...}, statistics: {...}, video: {...}, ... }\n\n```\n\nSee the [post types](src/types/post.d.ts) for the complete response object.\n\n#### .listPosts(params)\n\nLists a user's posts.\n\n```javascript\napi.listPosts({\n  user_id: '\u003cuser_id\u003e',\n  max_cursor: 0,\n})\n  .then(res =\u003e console.log(res.data.aweme_list))\n  .catch(console.log);\n\n// Outputs:\n// [{ author: {...}, aweme_id: '999', desc: 'description', music: {...}, statistics: {...}, video: {...} }, ...]\n\n```\n\nSee the [post types](src/types/post.d.ts) for the complete request/response objects.\n\n#### .listFollowers(params)\n\nLists the users that follow the specified user.\n\n```javascript\napi.listFollowers({\n  user_id: '\u003cuser_id\u003e',\n  max_time: Math.floor(new Date().getTime() / 1000),\n})\n  .then(res =\u003e console.log(res.data.followers))\n  .catch(console.log);\n\n// Outputs:\n// [{ unique_id: 'follower1' }, { unique_id: 'follower2' }, ...]\n\n```\n\nSee the [follower types](src/types/follower.d.ts) for the complete request/response objects.\n\n#### .listFollowing(params)\n\nLists the users that the specified user follows.\n\n```javascript\napi.listFollowing({\n  user_id: '\u003cuser_id\u003e',\n  max_time: Math.floor(new Date().getTime() / 1000),\n})\n  .then(res =\u003e console.log(res.data.followings))\n  .catch(console.log);\n\n// Outputs:\n// [{ unique_id: 'following1' }, { unique_id: 'following2' }, ...]\n\n```\n\nSee the [following types](src/types/follower.d.ts) for the complete request/response objects.\n\n#### .follow(id)\n\nFollows a user.\n\n```javascript\napi.follow('\u003cuser_id\u003e')\n  .then(res =\u003e console.log(res.data.follow_status))\n  .catch(console.log);\n\n// Outputs:\n// 1\n\n```\n\nSee the [follow types](src/types/follow.d.ts) for the response data.\n\n#### .unfollow(id)\n\nStops following a user.\n\n```javascript\napi.unfollow('\u003cuser_id\u003e')\n  .then(res =\u003e console.log(res.data.follow_status))\n  .catch(console.log);\n\n// Outputs:\n// 0\n\n```\n\nSee the [follow types](src/types/follow.d.ts) for the response data.\n\n#### .listReceivedFollowRequests(params)\n\nLists the users that have requested to follow the logged in user.\n\n```javascript\napi.listReceivedFollowRequests({\n  max_time: Math.floor(new Date().getTime() / 1000),\n  count: 10,\n})\n  .then(res =\u003e console.log(res.data.request_users))\n  .catch(console.log);\n\n// Outputs:\n// [{ unique_id: 'user1' }, { unique_id: 'user2' }, ...]\n\n```\n\nSee the [follow types](src/types/follow.d.ts) for the complete request/response objects.\n\n#### .approveFollowRequest(id)\n\nApproves a user's request to follow you.\n\n```javascript\napi.approveFollowRequest('\u003cuser_id\u003e')\n  .then(res =\u003e console.log(res.data.approve_status))\n  .catch(console.log);\n\n// Outputs:\n// 0\n\n```\n\nSee the [follow types](src/types/follow.d.ts) for the response data.\n\n#### .rejectFollowRequest(id)\n\nRejects a user's request to follow you.\n\n```javascript\napi.rejectFollowRequest('\u003cuser_id\u003e')\n  .then(res =\u003e console.log(res.data.reject_status))\n  .catch(console.log);\n\n// Outputs:\n// 0\n\n```\n\nSee the [follow types](src/types/follow.d.ts) for the response data.\n\n#### .likePost(id)\n\nLikes a post.\n\n```javascript\napi.likePost('\u003cpost_id\u003e')\n  .then(res =\u003e console.log(res.data.is_digg))\n  .catch(console.log);\n\n// Outputs:\n// 1\n\n```\n\n#### .unlikePost(id)\n\nUnlikes a post.\n\n```javascript\napi.unlikePost('\u003cpost_id\u003e')\n  .then(res =\u003e console.log(res.data.is_digg))\n  .catch(console.log);\n\n// Outputs:\n// 0\n\n```\n\n#### .listComments(params)\n\nLists comments for a post.\n\n```javascript\napi.listComments({\n  aweme_id: '\u003cpost_id\u003e',\n  cursor: 0,\n})\n  .then(res =\u003e console.log(res.data.comments))\n  .catch(console.log);\n\n// Outputs:\n// [{ text: 'first!', user: {...} }, { text: 'second!', user: {...} }, ...]\n\n```\n\nSee the [comment types](src/types/comment.d.ts) for the response data.\n\n#### .postComment(postId, text, [tags])\n\nComments on a post.\n\n```javascript\napi.postComment('\u003cpost_id\u003e', 'first!')\n  .then(res =\u003e console.log(res.data.comment))\n  .catch(console.log);\n\n// Outputs:\n// { cid: '\u003ccomment_id\u003e', text: 'first!', user: {...}, ... }\n\n```\n\nSee the [comment types](src/types/comment.d.ts) for the response data.\n\n#### .listCategories(params)\n\nLists popular categories/hashtags.\n\n```javascript\napi.listCategories({\n  count: 10,\n  cursor: 0,\n})\n  .then(res =\u003e console.log(res.data.category_list))\n  .catch(console.log);\n\n// Outputs:\n// [{ { challenge_info: { cha_name: 'posechallenge', cid: '123' }, desc: 'Trending Hashtag' }, ...]\n\n```\n\nSee the [category types](src/types/category.d.ts) for the complete request/response objects.\n\n#### .searchHashtags(params)\n\nSearches for hashtags.\n\n```javascript\napi.searchHashtags({\n  keyword: 'example',\n  count: 10,\n  cursor: 0,\n})\n  .then(res =\u003e console.log(res.data.challenge_list))\n  .catch(console.log);\n\n// Outputs:\n// [{ challenge_info: {...}, position: [] }, ...]\n\n```\n\nSee the [search types](src/types/search.d.ts) for the complete request/response objects.\n\n#### .listPostsInHashtag(params)\n\nLists posts in a hashtag.\n\n```javascript\napi.listPostsInHashtag({\n  ch_id: '\u003chashtag_id\u003e',\n})\n  .then(res =\u003e console.log(res.data.aweme_list))\n  .catch(console.log);\n\n// Outputs:\n// [{ author: {...}, aweme_id: '999', desc: 'description', music: {...}, statistics: {...}, video: {...} }, ...]\n\n```\n\nSee the [hashtag types](src/types/hashtag.d.ts) for the complete request/response objects.\n\n#### .listForYouFeed([params])\n\nLists posts in the For You feed.\n\n```javascript\napi.listForYouFeed()\n  .then(res =\u003e console.log(res.data.aweme_list))\n  .catch(console.log);\n\n// Outputs:\n// [{ author: {...}, aweme_id: '999', desc: 'description', music: {...}, statistics: {...}, video: {...} }, ...]\n\n```\n\nSee the [feed types](src/types/feed.d.ts) for the complete request/response objects.\n\n#### .listFollowingFeed([params])\n\nLists posts in the Following feed.\n\n```javascript\napi.listFollowingFeed()\n  .then(res =\u003e console.log(res.data.aweme_list))\n  .catch(console.log);\n\n// Outputs:\n// [{ author: {...}, aweme_id: '999', desc: 'description', music: {...}, statistics: {...}, video: {...} }, ...]\n\n```\n\nSee the [feed types](src/types/feed.d.ts) for the complete request/response objects.\n\n#### .getSticker(id)\n\nGets information about a sticker/effect.\n\n```javascript\napi.getSticker('\u003csticker_id\u003e')\n  .then(res =\u003e console.log(res.data.sticker_infos))\n  .catch(console.log);\n\n// Outputs:\n// [{ id: '100000', name: 'cloned', owner_nickname: 'Effect Assistant', ...}]\n\n```\n\nSee the [sticker types](src/types/sticker.d.ts) for the complete response object.\n\n#### .getStickers([ids])\n\nGets information about many stickers/effects.\n\n```javascript\napi.getStickers(['\u003csticker_id\u003e', '\u003csticker_id\u003e'])\n  .then(res =\u003e console.log(res.data.sticker_infos))\n  .catch(console.log);\n\n// Outputs:\n// [{ id: '100000', name: 'cloned', owner_nickname: 'Effect Assistant', ...}, ...]\n\n```\n\nSee the [sticker types](src/types/sticker.d.ts) for the complete response object.\n\n#### .listPostsBySticker(params)\n\nLists posts that use a sticker/effect.\n\n```javascript\napi.listPostsBySticker({\n  count: 20,\n  cursor: 0,\n  sticker_id: '100000',\n})\n  .then(res =\u003e console.log(res.data.aweme_list))\n  .catch(console.log);\n\n// Outputs:\n// [{ author: {...}, aweme_id: '999', desc: 'description', music: {...}, statistics: {...}, video: {...} }, ...]\n```\n\nSee the [sticker types](src/types/sticker.d.ts) for the complete request/response object.\n\n#### .joinLiveStream(id)\n\nJoins a live stream.  \n\nThe `rtmp_pull_url` value can be used with VLC's `Open Network Stream` option.\n\n```javascript\napi.joinLiveStream('\u003croom_id\u003e')\n  .then(res =\u003e console.log(res.data.room))\n  .catch(console.log);\n\n// Outputs:\n// { create_time: 1000000000, owner: {...}, stream_url: {...}, title: 'Example', user_count: 1000, ... }\n\n```\n\nSee the [live stream types](src/types/live-stream.d.ts) for the response data.\n\n#### .leaveLiveStream(id)\n\nLeaves a live stream.\n\n```javascript\napi.leaveLiveStream('\u003croom_id\u003e')\n  .then(res =\u003e console.log(res.data.status_code))\n  .catch(console.log);\n\n// Outputs:\n// 0\n\n```\n\n#### .canStartLiveStream()\n\nDetermines if the current user is allowed to start a live stream.\n\n```javascript\napi.canStartLiveStream()\n  .then(res =\u003e console.log(res.data.can_be_live_podcast))\n  .catch(console.log);\n\n// Outputs:\n// true\n\n```\n\nSee the [live stream types](src/types/live-stream.d.ts) for the response data.\n\n#### .startLiveStream(title, [contactsAuthorized])\n\nStarts a live stream by calling [`createLiveStreamRoom`](#createlivestreamroomtitle-contactsauthorized)\nthen [`updateLiveStreamStatus`](#updatelivestreamstatusparams).\n\nKeep note of the `room_id` and `stream_id` properties because you will need them to end the live stream.\n\nThe `rtmp_push_url` value can be used with streaming applications such as OBS.\n\n```javascript\napi.startLiveStream('title')\n  .then(res =\u003e console.log(res.data.room))\n  .catch(console.log);\n\n// Outputs:\n// { create_time: 1000000000, owner: {...}, stream_url: {...}, title: 'Example', user_count: 1000, ... }\n\n```\n\nSee the [live stream types](src/types/live-stream.d.ts) for the response data.\n\n#### .endLiveStream(roomId, streamId)\n\nEnds a live stream.\n\nYou **must** call this method to so you are no longer marked as \"live\" in the app.\n\n```javascript\napi.endLiveStream('\u003croom_id\u003e', '\u003cstream_id\u003e')\n  .then(res =\u003e console.log(res.data.status_code))\n  .catch(console.log);\n\n// Outputs:\n// 0\n\n```\n\n#### .createLiveStreamRoom(title, [contactsAuthorized])\n\nCreates a room to host a live stream.\n\nThe `rtmp_push_url` value can be used with streaming applications such as OBS.\n\n**Note:** This method only creates the room for the live stream.  You'll need to call\n[`updateLiveStreamStatus`](#updatelivestreamstatusparams) to mark the stream as started.\nSee [`startLiveStream`](#startlivestreamtitle-contactsauthorized) for a helper method that makes these calls for you.\n\n```javascript\napi.startLiveStream('title')\n  .then(res =\u003e console.log(res.data.room))\n  .catch(console.log);\n\n// Outputs:\n// { create_time: 1000000000, owner: {...}, stream_url: {...}, title: 'Example', user_count: 1000, ... }\n\n```\n\nSee the [live stream types](src/types/live-stream.d.ts) for the response data.\n\n#### .updateLiveStreamStatus(params)\n\nUpdates the status of a live stream.\n\n```javascript\napi.updateLiveStreamStatus({\n  room_id: '\u003croom_id\u003e',\n  stream_id: '\u003cstream_id\u003e',\n  status: LiveStreamStatus.Ended,\n  reason_no: LiveStreamStatusChangedReason.InitiatedByUser,\n})\n  .then(res =\u003e console.log(res.data.status_code))\n  .catch(console.log);\n\n// Outputs:\n// 0\n\n```\n\nSee the [live stream types](src/types/live-stream.d.ts) for the complete request/response objects.\n\n## Resources\n\n* [Reverse engineering the musical.ly API](https://medium.com/@szdc/reverse-engineering-the-musical-ly-api-662331008eb3)\n\n## Legal\n\nThis code is in no way affiliated with, authorized, maintained, sponsored or endorsed by TikTok\nor any of its affiliates or subsidiaries. This is an independent and unofficial API. Use at your own risk.\n","funding_links":[],"categories":["1. [↑](#-content) OSINT","TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszdc%2Ftiktok-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fszdc%2Ftiktok-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszdc%2Ftiktok-api/lists"}