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!