3

I have searched for many days now, but didn't found a field in the TikTok API where I can get the username of the user that has connected his TikTok account with my website. I want to let user log in with their TikTok account to let them link it from my website to TikTok and want to display their "@" name (not the display name. I can only get their IDs etc. but no their username. If anyone can help I'd be very happy!

I searched on many forums for this but didn't sound any solution. I'm expecting to be able to send a request to the official TikTok API which then replies the username of someones ID or of someones Token I own.

2 Answers2

2

On Get User Info API route you can put username on fields arguments like this :

https://open.tiktokapis.com/v2/user/info/?fields=profile_deep_link,username

This field username is not documented (maybe a mistake in TikTok side) but it work well for me, you can see the screenshot : enter image description here

JC Guidicelli
  • 1,296
  • 7
  • 16
0

As the TikTok API only provides the display name, the only workaround we have found so far is to fetch the videos of your user, and parse the share-url to extract the username from the first video. You just have to pray that he has got at least one.

Query the videos of your user:

curl -L -X POST 'https://open.tiktokapis.com/v2/video/list/?fields=share_url' -H 'Authorization: Bearer XXXXX' \ -H 'Content-Type: application/json' \ --data-raw '{ "max_count": 1 }'

Here, the token you provide tells the API which user you are talking about.

The share-url looks like this: https://www.tiktok.com/@USERNAME/video/VIDEO-ID?utm_campaign=tt2d_open_api&utm_source=aaaa

Thomzs
  • 21
  • 4