|
// hier ein NodeJS Beispiel |
|
|
|
const fetch = require('node-fetch') |
|
const token = '' // 361 Zeichen lang |
|
|
|
function GetUserpointsForSpecificUsername(chan, user) { // https://docs.streamelements.com/reference/single-user#pointsbychannelanduserget |
|
fetch('https://api.streamelements.com/kappa/v2/points/' + chan + '/' + user, { method: 'GET', headers: { Accept: 'application/json', Authorization: 'Bearer ' + token } }) |
|
.then(res => res.json()) |
|
.then(json => console.log(json)) |
|
.catch(err => console.error('error:' + err)) |
|
// Response: { |
|
// channel: '5f89f7f37573f5360e4bae13', |
|
// username: 'spddl', |
|
// points: 5, |
|
// pointsAlltime: 150, |
|
// watchtime: 0, |
|
// rank: 1 |
|
// } |
|
} |
|
GetUserpointsForSpecificUsername('5f89f7f37573f5360e4bae13', 'spddl') |
|
|
|
function UpdateAllTimePointsForUser(channel, user, amount) { // https://docs.streamelements.com/reference/single-user#pointsalltimeamountbychannelanduserput |
|
fetch(`https://api.streamelements.com/kappa/v2/points/${channel}/alltime/${user}/${amount}`, { |
|
method: 'PUT', |
|
headers: { Accept: 'application/json', 'Content-Type': 'text/plain', Authorization: 'Bearer ' + token } |
|
}) |
|
.then(res => res.json()) |
|
.then(json => console.log(json)) |
|
.catch(err => console.error('error:' + err)) |
|
// Response(+100): { |
|
// channel: '5f89f7f37573f5360e4bae13', |
|
// username: 'spddl', |
|
// amount: 100, |
|
// newAmount: 200, |
|
// message: 'Added 100 points to user spddl' |
|
// } |
|
// Response(-50): { |
|
// channel: '5f89f7f37573f5360e4bae13', |
|
// username: 'spddl', |
|
// amount: -50, |
|
// newAmount: 150, |
|
// message: 'Removed -50 points to user spddl' |
|
// } |
|
} |
|
UpdateAllTimePointsForUser('5f89f7f37573f5360e4bae13', 'spddl', 100) |
|
UpdateAllTimePointsForUser('5f89f7f37573f5360e4bae13', 'spddl', -50) |