Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Scratch API get Total Follower Count
- -Snipet-
- Scratcher
500+ posts
Scratch API get Total Follower Count
Basically what the title says. I know how to get the followers of a particular user, but it just shows a few. How do I get the total amount?
- _nix
- Scratcher
1000+ posts
Scratch API get Total Follower Count
There is no API for this (though they might add one eventually). For now the only way to get the follower count of a user is to parse the HTML to find the number on the user's /followers/ page.
══ trans autistic lesbian enbydoggirls // 16 17 18 19 20 21, she/they ════
sparrows one word to the paragraph // <3 // ~(quasar) nebula
- -Snipet-
- Scratcher
500+ posts
Scratch API get Total Follower Count
the user's /followers/ page.Oh yeah. I completely overlooked that. Thanks! There is no API for this (though they might add one eventually). For now the only way to get the follower count of a user is to parse the HTML to find the number on
Last edited by -Snipet- (March 24, 2019 18:18:38)
- -Bonfire-
- Scratcher
59 posts
Scratch API get Total Follower Count
You could make one yourselfthe user's /followers/ page.Oh yeah. I completely overlooked that. Thanks! There is no API for this (though they might add one eventually). For now the only way to get the follower count of a user is to parse the HTML to find the number on
-Bonfire- can code
- Movies22_by_TR
- Scratcher
19 posts
Scratch API get Total Follower Count
the user's /followers/ page.well, i tried doing that using node-fetch, but i got a empty response: There is no API for this (though they might add one eventually). For now the only way to get the follower count of a user is to parse the HTML to find the number on
<html><head></head><body></body></html>
- _nix
- Scratcher
1000+ posts
Scratch API get Total Follower Count
Huh, that's really weird! It definitely didn't error like that for me in the past, and looking at the code for other libraries for interfacing with Scratch, I don't see anything different. (I tested myself and got the same response.)the user's /followers/ page.well, i tried doing that using node-fetch, but i got a empty response: There is no API for this (though they might add one eventually). For now the only way to get the follower count of a user is to parse the HTML to find the number on. How can i parse the HTML then?<html><head></head><body></body></html>
Apparently api.scratch.mit.edu still works fine, so you could try using that. It (still) doesn't have a follow count directly accessible anywhere, but you can calculate it by making repeated requests at different follower offsets to narrow in on the precise count.
E.g, make a number of requests like this:
- https://api.scratch.mit.edu/users/_nix/followers/?offset=0&limit=40 —
Response array length is full (40 items, max length for API) so there are more than 40 followers. - https://api.scratch.mit.edu/users/_nix/followers/?offset=40&limit=40 —
Length is 40 so there are more than 80 followers. - https://api.scratch.mit.edu/users/_nix/followers/?offset=80&limit=40 —
Length is 40 so there are more than 120 followers. - https://api.scratch.mit.edu/users/_nix/followers/?offset=160&limit=40 —
Length is 40 so there are more than 180 followers. - https://api.scratch.mit.edu/users/_nix/followers/?offset=320&limit=40 —
Length is 40 so there are more than 360 followers. - https://api.scratch.mit.edu/users/_nix/followers/?offset=640&limit=40 —
Length is 0 so there are less than 640 followers—we've overshot, so start counting down. Halfway between 360 and 640 is 500… - https://api.scratch.mit.edu/users/_nix/followers/?offset=500&limit=40 —
Length is 40 so there are more than 540 followers. Just count up from here since we must be pretty close. - https://api.scratch.mit.edu/users/_nix/followers/?offset=540&limit=40 —
Length is 8 so there are precisely 540 + 8 = 548 followers.
…Okay, so, 548 is more than what it says on my profile, but it is exactly what is shown when I delete my account (“You joined the Scratch community 5 years ago. You've created 907 projects and have 548 followers.”), so yaknow (I think deleted accounts are included? I haven't researched this carefully.)
I definitely didn't use the most generally efficient algorithm here, but in general this will always take at least a few requests (more for accounts with more followers), so make sure you're appropriately rate limiting yourself (like only making 5 requests a second for example). Otherwise you risk getting in trouble for overloading the Scratch APIs.
Last edited by _nix (Jan. 2, 2022 19:47:45)
══ trans autistic lesbian enbydoggirls // 16 17 18 19 20 21, she/they ════
sparrows one word to the paragraph // <3 // ~(quasar) nebula
- mybearworld
- Scratcher
1000+ posts
Scratch API get Total Follower Count
Signatures are the only place where assets links still work.
- ScolderCreations
- Scratcher
1000+ posts
Scratch API get Total Follower Count
That makes sense, the reason is probably to prevent bots from spamming those pages with requests.
- Movies22_by_TR
- Scratcher
19 posts
Scratch API get Total Follower Count
Well, there is no way to do it easly/fast. Because i was working in a live followers counter and I needed to get the followers count of every second.Huh, that's really weird! It definitely didn't error like that for me in the past, and looking at the code for other libraries for interfacing with Scratch, I don't see anything different. (I tested myself and got the same response.)the user's /followers/ page.well, i tried doing that using node-fetch, but i got a empty response: There is no API for this (though they might add one eventually). For now the only way to get the follower count of a user is to parse the HTML to find the number on. How can i parse the HTML then?<html><head></head><body></body></html>
Apparently api.scratch.mit.edu still works fine, so you could try using that. It (still) doesn't have a follow count directly accessible anywhere, but you can calculate it by making repeated requests at different follower offsets to narrow in on the precise count.
E.g, make a number of requests like this:
- https://api.scratch.mit.edu/users/_nix/followers/?offset=0&limit=40 —
Response array length is full (40 items, max length for API) so there are more than 40 followers.- https://api.scratch.mit.edu/users/_nix/followers/?offset=40&limit=40 —
Length is 40 so there are more than 80 followers.- https://api.scratch.mit.edu/users/_nix/followers/?offset=80&limit=40 —
Length is 40 so there are more than 120 followers.- https://api.scratch.mit.edu/users/_nix/followers/?offset=160&limit=40 —
Length is 40 so there are more than 180 followers.- https://api.scratch.mit.edu/users/_nix/followers/?offset=320&limit=40 —
Length is 40 so there are more than 360 followers.- https://api.scratch.mit.edu/users/_nix/followers/?offset=640&limit=40 —
Length is 0 so there are less than 640 followers—we've overshot, so start counting down. Halfway between 360 and 640 is 500…- https://api.scratch.mit.edu/users/_nix/followers/?offset=500&limit=40 —
Length is 40 so there are more than 540 followers. Just count up from here since we must be pretty close.- https://api.scratch.mit.edu/users/_nix/followers/?offset=540&limit=40 —
Length is 8 so there are precisely 540 + 8 = 548 followers.
…Okay, so, 548 is more than what it says on my profile, but it is exactly what is shown when I delete my account (“You joined the Scratch community 5 years ago. You've created 907 projects and have 548 followers.”), so yaknow (I think deleted accounts are included? I haven't researched this carefully.)
I definitely didn't use the most generally efficient algorithm here, but in general this will always take at least a few requests (more for accounts with more followers), so make sure you're appropriately rate limiting yourself (like only making 5 requests a second for example). Otherwise you risk getting in trouble for overloading the Scratch APIs.
- god286
- Scratcher
1000+ posts
Scratch API get Total Follower Count
Webscraping could be an option. Well, there is no way to do it easly/fast. Because i was working in a live followers counter and I needed to get the followers count of every second.
document.querySelector(".box-head > h2:nth-child(2)").innerText // me » Followers (12345)"
Here are some of my followers!
I joined: 5 years, 9 months, 24 days ago (31/03/2018)
I have: 479 followers
In total, I have attained: 1,403 loves, 1,145 favourites, and 33,731 views.
Fun Fact: If my account continued to gain followers at a similar rate to right now, in 14,210 years I would reach the number of followers griffpatch has today! Try to imagine how many followers he would have then!
Thank you everyone!
Script created by god286.
- Wetbikeboy2500
- Scratcher
100+ posts
Scratch API get Total Follower Count
Webscraping could be an option. Well, there is no way to do it easly/fast. Because i was working in a live followers counter and I needed to get the followers count of every second.document.querySelector(".box-head > h2:nth-child(2)").innerText // me » Followers (12345)"
This is for the top of the followers page where it displays the total number of followers a user has. This makes it a single request.
You can then use some regex on it to extract the specific number
/\((\d+)\)/g.exec(document.querySelector('.box-head h2').innerText)[1]
Last edited by Wetbikeboy2500 (Jan. 4, 2022 19:58:31)
Scratch Made In JavaScript: https://scratch.mit.edu/discuss/topic/171842
Scratch Browser: https://scratch.mit.edu/discuss/topic/285957/
SB2Downloader: https://scratch.mit.edu/discuss/topic/295425/
Multiple work stations: https://scratch.mit.edu/discuss/topic/122484/
New Blocks for Displaying Text: https://scratch.mit.edu/discuss/topic/171508
Sprite Folders: https://scratch.mit.edu/discuss/topic/171569/
Find code easier: https://scratch.mit.edu/discuss/topic/144748/
A Support Button or No support Button: https://scratch.mit.edu/discuss/topic/181154/
I want Scratch grow and become a better place for everyone to come and use. So Scratch needs to expand and have more options for everyone.Scratch needs to break the boundaries and not be trapped by what is familiar to Scratch community
- coolcoder1213
- Scratcher
100+ posts
Scratch API get Total Follower Count
ScratchDB offers the stats for the amount of followers you have but not the amount. You would have to web-scrape.
So, this is just a signature.
Scratchleton - Hamilton Mod
Cloud Stats Projects
My Profile:
coolcoder1213
I am great at cloud variables and Python.
- MagicCrayon9342
- Scratcher
1000+ posts
Scratch API get Total Follower Count
You can simply grab it from the api directly. Using a CORS proxy.
Here's a list of them
A list inside a list.
Always online, fast, and free. I literally never update it, its just as cors-anywhere instance which you CAN host yourself.
Here's a list of them
A list inside a list.
Always online, fast, and free. I literally never update it, its just as cors-anywhere instance which you CAN host yourself.
- NFlex23
- Scratcher
1000+ posts
Scratch API get Total Follower Count
(#13)I don't think you read the OP carefully. You don't even need a proxy for the Scratch API anyway.
You can simply grab it from the api directly. Using a CORS proxy.
Here's a list of them
A list inside a list.
Always online, fast, and free. I literally never update it, its just as cors-anywhere instance which you CAN host yourself.
Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
- Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
- The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
- Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
- Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
- Issues with Scratch itself should be put in Bugs and Glitches.
- MagicCrayon9342
- Scratcher
1000+ posts
Scratch API get Total Follower Count
You can do it manually but a CORS proxy is just easier.(#13)I don't think you read the OP carefully. You don't even need a proxy for the Scratch API anyway.
You can simply grab it from the api directly. Using a CORS proxy.
Here's a list of them
A list inside a list.
Always online, fast, and free. I literally never update it, its just as cors-anywhere instance which you CAN host yourself.
From a website you WILL need a CORS proxy or that manual method.
- Steve0Greatness
- Scratcher
1000+ posts
Scratch API get Total Follower Count
ScratchDB has a page for this:
this returns a JSON of info about the user in question. The total follower count is under the keys statistics, then followers.
https://scratchdb.lefty.one/v3/user/info/:user
/hj is the worst tone indicator. It's confusing and ambiguous. I hate it. The point of tone indicators is to indicate tone, or the way that a piece of text should be read, but what does “half joking” mean? Do you just wake up in the morning and think “wow, I really have something I want to talk about seriously but also kinda not, IDK you decide.” It's useless. I hate it. It just provokes a deep rooted anger within me whenever I see it. People just comment /hj as if it makes any sense. It doesn't. Oh wow, it's a tone indicator that's has a relative meaning, how useful, I'll use it in every comment I post. NO. STOP IT. You're a tone indicator, you have only one job, and yet you sit there doing nothing apart angering me.
/srs
^^^ (there's more below)
This one is useful because it tells you that this signature is fully 100% serious. (/srs) Who would've thought that tone indicators needed to tell you something about the piece of text they're attached to? /s
I'm serious, I'm not even going to put multiple (/hj)s a the end of my signature as to mock the previous paragraph for not getting the point of something(like previous version of my signature). /srs
- MagicCrayon9342
- Scratcher
1000+ posts
Scratch API get Total Follower Count
To clear some confusion, if you ever see a ‘:’ before a value in a URL of an express application that means that's a value to replace with the ‘user’ in this case. Not sure why everyone includes the colon as its only necessary in the code itself. Confused me at one point. ScratchDB has a page for this:this returns a JSON of info about the user in question. The total follower count is under the keys statistics, then followers.https://scratchdb.lefty.one/v3/user/info/:user
- NFlex23
- Scratcher
1000+ posts
Scratch API get Total Follower Count
(#17)It's to show people that you replace it with an arbitrary value. If you didn't include the colon it would be even more confusing.To clear some confusion, if you ever see a ‘:’ before a value in a URL of an express application that means that's a value to replace with the ‘user’ in this case. Not sure why everyone includes the colon as its only necessary in the code itself. Confused me at one point. ScratchDB has a page for this:this returns a JSON of info about the user in question. The total follower count is under the keys statistics, then followers.https://scratchdb.lefty.one/v3/user/info/:user
Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
- Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
- The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
- Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
- Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
- Issues with Scratch itself should be put in Bugs and Glitches.
- Discussion Forums
- » Advanced Topics
- » Scratch API get Total Follower Count