+ 6
[resolved] Fetching data from an API.
Hey, I was trying to getting the data from this API: https://api2.sololearn.com/v2/userinfo/v3/profile/19137863 It's a new API i think, available with the new structure of the SoloLearn website. I was trying to get info of users with their ID, but I don't know how to use this api, like wich commands to use. Can anyone please help me to get data like summary, level, follow (if possible), courses lenght,... Here my try to get some data, but I don't know the method so it doesn't work. Hope you understand me & thanks in advance :) https://code.sololearn.com/WsZyWSZQyaxH/?ref=app
21 Answers
+ 10
Try this in this code i have printed the data clearly so it is easier for you to understand and decide how to get values
May it help you Major
https://code.sololearn.com/WrGeCQ3UDnKW/?ref=app
+ 6
StepBill Only some info for a project, & wanna try something, like then I don't have manually like to update the followers etc.
+ 5
Thank you soooooooo much Arnav Kumar [📕Schools📚] , now I understood, thanks a lot :) 🦊
+ 5
Major from where you got this api?
+ 5
Krish [less active] i found that one 😁
+ 5
Arnav Kumar [📕Schools📚]
Do they openly provide in their site
https://sololearn.com/
Or you got it on a blog?
+ 4
Welcome Major
+ 4
From where Arnav Kumar [📕Schools📚] bruh
I mean how you got that link
+ 4
Krish [less active] sl website
+ 4
Krish [less active] i meant by inspecting the site
+ 3
Thanks Abhay , do you know how to print other info too? :)
Is it Always the same structure, data.userDetails....?
Thanks a lot Abhay :)
+ 3
Lisa Larry firstable I suggest you to use the search bar, to avoid duplicate questions. :)
May this can be helpful:
https://www.sololearn.com/discuss/137697/?ref=app
https://www.sololearn.com/discuss/595802/?ref=app
https://www.sololearn.com/discuss/1589935/?ref=app
https://www.sololearn.com/discuss/1091816/?ref=app
https://www.sololearn.com/discuss/452538/?ref=app
https://www.sololearn.com/discuss/453081/?ref=app
https://www.sololearn.com/discuss/333866/?ref=app
https://www.sololearn.com/post/947721/?ref=app
Hope it helps :)
All the best ✨
+ 2
Log out the keys of the json object to see what property to select.
var b = await a.json()
var data= b;
for(let i in data){
console.log(i);
}
console.log(data.userDetails.name) //will print the user name
+ 2
Major what other info you need?
there are many other properties , just loop over them to find the new keys.
like,
for(let i in data.userDetails) {
console.log(i)
}
+ 2
Major data.userDetails.level and data.userDetails.bio
+ 2
🔥💥holyboi💥🔥 you can create your own question or only dm Arnav.
Because this is a bit offtopic now. Thanks :)
+ 2
🔥💥holyboi💥🔥 thanks but I think they used api v.1, but now it doesn't work because of the new update.
Btw thanks :)
+ 2
Lisa Larry you can create your own question.
Because this is a bit offtopic now. Thanks :)
+ 1
What do you want the data for? Just wondering...
0
pls who can help me am new