Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Ability to Retrieve Following/Followed Users #8

Open
M1kep opened this issue Jan 2, 2023 · 11 comments
Open

[Feature Request] Ability to Retrieve Following/Followed Users #8

M1kep opened this issue Jan 2, 2023 · 11 comments
Labels
enhancement New feature or request

Comments

@M1kep
Copy link

M1kep commented Jan 2, 2023

No description provided.

@Russell-Newton
Copy link
Owner

TikTok does not provide any API or interface to find this information about any User other than yourself (when logged in). You can only view your own follow/following lists, even in the app or on the website.

As far as I know, this is impossible to do unless TikTok makes this available somehow.

@Russell-Newton Russell-Newton closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2023
@hopperelec
Copy link

This is still useful for retrieving your own following/followed users. For example, I'm writing a program to give me desktop notifications when someone I'm following posts a new TikTok. It's actually pretty simple to retrieve, too- you just need a sessionid. Here's how I did it using Python requests

def get_following():
    print("Getting following list")
    return requests.get(
            "https://www.tiktok.com/api/user/list",
            {"count": 10000, "minCursor": 0},
            cookies={"sessionid": SESSION_ID}
    ).json()['userList']

@Russell-Newton
Copy link
Owner

This is still useful for retrieving your own following/followed users. For example, I'm writing a program to give me desktop notifications when someone I'm following posts a new TikTok. It's actually pretty simple to retrieve, too- you just need a sessionid. Here's how I did it using Python requests

def get_following():
    print("Getting following list")
    return requests.get(
            "https://www.tiktok.com/api/user/list",
            {"count": 10000, "minCursor": 0},
            cookies={"sessionid": SESSION_ID}
    ).json()['userList']

Is the sessionid linked to a specific login?

@Russell-Newton Russell-Newton reopened this Jan 7, 2023
@hopperelec
Copy link

I've used the same session ID for a few days now and it hasn't expired, so either it has a long expiration date or it isn't linked to a specific login. And if it is, I remember seeing something about how to obtain a new session ID anyways

@Russell-Newton
Copy link
Owner

It seems like it would need to be linked to a login if that's the only information provided to the API to collect the list of followed by a specific account. There's no other information about what account to get that information for as far as I can tell.

@hopperelec
Copy link

Oh I thought by login you meant it would expire if you get logged out, but I'm guessing you just mean account. Yes, it's linked to your account

@Russell-Newton
Copy link
Owner

Russell-Newton commented Jan 7, 2023

After poking around a bit, it looks like the endpoint https://www.tiktok.com/api/user/list/ is used to populate following and followers lists. This endpoint can be used anonymously if the following parameters are passed:

  • count - number of users to grab (max 200 I think, else status_code 10101)
  • minCursor=0 - this is used to set which users to grab. the minCursor value set in the API response can be passed back to the API to get the next set. Once this is -1, you've reached the end
  • secUid - the secUid of the user to grab the info for
  • scene - if null or 21, returns the following list; if 67 returns the followers list

Returns an object with status code 10222 if privacy settings blocks this. Presumably, having a session ID that corresponds to being logged in to the account in question would bypass the privacy settings.

With this in mind, this is definitely a feature that can be implemented. I'll get working on it.

@Russell-Newton
Copy link
Owner

There's a new interesting issue I'm seeing when trying to use this endpoint, I can only ever seem to get up to about 4.5 thousand results through the iterative process with minCursor

@hopperelec
Copy link

hopperelec commented Jan 8, 2023

There's a new interesting issue I'm seeing when trying to use this endpoint, I can only ever seem to get up to about 4.5 thousand results through the iterative process with minCursor

I'm curious how you tested this so quickly- do you just casually follow that many people anyways? I thought I was bad for following 21 people lol.

Thanks for developing this module so actively, by the way!

@Russell-Newton
Copy link
Owner

Russell-Newton commented Jan 8, 2023

There's a new interesting issue I'm seeing when trying to use this endpoint, I can only ever seem to get up to about 4.5 thousand results through the iterative process with minCursor

I'm curious how you tested this so quickly- do you just casually follow that many people anyways? I thought I was bad for following 21 people lol.

Thanks for developing this module so actively, by the way!

No lol it was actually somewhat tricky to find an account that followed ~5000 people and had ~5000 followers. TikTok really likes promoting content and creators it thinks you will like, so I had to go down quite a rabbit hole before I could find an account to test with. It was easy to find an account with a large number of followers (TikTok itself has over 60 mil) so that's what I initially tested with.

@hopperelec
Copy link

Oh, I didn't even realise you could view the accounts following/followed (by) an account you're not logged into at all. Goes to show how little I use TikTok I suppose 😅

@Russell-Newton Russell-Newton added the enhancement New feature or request label Jan 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants