Last follower/All followers and Last subscriber/Last subscribers

Hi, I am programming a simple application. The application should detect the last follower, the last subscriber/all subscribers and I am wondering how to achieve this! I program in node.js and even with ChatGPT I am not able to create a working API and I have tried maybe 30 modifications to my code, so what API should I use to get this data?

My last code…

import { ApiClient } from ‘twitch’;
import { ClientCredentialsAuthProvider } from ‘twitch-auth’;

// Setting up your app with a Twitch API key
const clientId = ‘';
const clientSecret = '
’;
const authProvider = new ClientCredentialsAuthProvider(clientId, clientSecret);
const apiClient = new ApiClient({ authProvider });

// Get user id by login name
async function getLastFollower(username) {
try {
const users = await apiClient.helix.users.getUsersByNames([username]);
const user = users[0];

if (!user) {
console.error(User not found: ${username});
return;
}

// Get the list of followers
const followers = await apiClient.helix.users.getFollows({ followedUser: user.id, first: 1 });
if (followers.data.length > 0) {
const lastFollower = followers.data[0];
console.log(Last follower: ${lastFollower.userDisplayName});
} else {
console.log(‘No followers found.’);
}
} catch (err) {
console.error(err);
}
}

// Replace ‘YOUR_TWITCH_USERNAME’ with your Twitch username
const username = ‘wwwkennyseqcom’;
getLastFollower(username);

And in the console I get the error 410(This API is not available.) as in most cases of other code modifications.
Then I have another one that returns the number of all my followers but the data is already empty so I don’t get the name.
So which APIs are the latest and correct?

Thank you for your response!

Followers:
I have run into the ‘only total follower count returned’ issue.

  • Requires a user access token that includes the moderator:read:followers scope.

  • The ID in the broadcaster_id query parameter must match the user ID in the access token or the user ID in the access token must be a moderator for the specified broadcaster.

  • This endpoint will return specific follower information only if both of the above are true. If a scope is not provided or the user isn’t the broadcaster or a moderator for the specified channel, only the total follower count will be included in the response.


Not sure about the library you’re using, though the secret is only used to authorize for obtaining an access token and not directly in the API call. In getting the access token, it needs to have the above criteria of that channel to access the individual follower names, not just the follower total count.

Subscriptions - similar details for subscriptions and access scopes:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.