Skip to content

Commit 9bdd7ef

Browse files
committed
Profile picture endpoint
1 parent 8e5ade0 commit 9bdd7ef

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ <h2>Endpoints</h2>
9797
<th scope="row"><a href='http://api.yucibot.nl/user/id/:user' target="_blank" class='apiLink'>/user/id/:user</a></th>
9898
<td>Shows the ID of a user</td>
9999
</tr>
100+
<tr>
101+
<th scope="row"><a href='http://api.yucibot.nl/user/pf/:user' target="_blank" class='apiLink'>/user/pf/:user</a></th>
102+
<td>Shows the URL of a user's profile picture</td>
103+
</tr>
100104
<tr>
101105
<th scope="row"><a href='http://api.yucibot.nl/user/followers/:user' target="_blank" class='apiLink'>/user/followers/:user</a></th>
102106
<td>Returns the amount of followers of a channel</td>

server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ user.followage(app, conf, reqst);
1515
user.followsince(app, conf, reqst);
1616
user.age(app, conf, reqst);
1717
user.id(app, conf, reqst);
18+
user.pf(app, conf, reqst);
1819
user.followers(app, conf, reqst);
1920
user.game(app, conf, reqst);
2021
user.title(app, conf, reqst);

user.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,23 @@ module.exports = {
107107
})
108108
});
109109
},
110+
pf: function(app, conf, reqst) {
111+
app.get('/user/pf/:user', function(req, res) {
112+
var usr = req.params.user
113+
var tId = conf.cInfo.id
114+
var info = {
115+
url: 'https://api.twitch.tv/kraken/users?login='+usr,
116+
headers: {
117+
'Client-ID': tId,
118+
'Accept': 'application/vnd.twitchtv.v5+json'
119+
}
120+
}
121+
reqst(info, function (error, response, body) {
122+
if (JSON.parse(body).users == undefined || JSON.parse(body).users[0] == undefined) return res.send("This user does not exist")
123+
res.send(JSON.parse(body).users[0].logo)
124+
})
125+
});
126+
},
110127
followers: function(app, conf, reqst) {
111128
app.get('/user/followers/:user', function(req, res) {
112129
var usr = req.params.user

0 commit comments

Comments
 (0)