+ 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

20th Feb 2021, 1:50 PM
Matthew
Matthew - avatar
22 odpowiedzi
+ 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
20th Feb 2021, 2:38 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 6
StepBill Only some info for a project, & wanna try something, like then I don't have manually like to update the followers etc.
21st Feb 2021, 6:43 AM
Matthew
Matthew - avatar
+ 5
Thank you soooooooo much Arnav Kumar [📕Schools📚] , now I understood, thanks a lot :) 🦊
20th Feb 2021, 2:41 PM
Matthew
Matthew - avatar
+ 5
Major from where you got this api?
21st Feb 2021, 3:04 AM
Krish
Krish - avatar
+ 5
Krish [less active] i found that one 😁
21st Feb 2021, 3:08 AM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 5
Arnav Kumar [📕Schools📚] Do they openly provide in their site https://sololearn.com/ Or you got it on a blog?
21st Feb 2021, 3:19 AM
Krish
Krish - avatar
+ 4
Welcome Major
20th Feb 2021, 2:44 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 4
From where Arnav Kumar [📕Schools📚] bruh I mean how you got that link
21st Feb 2021, 3:16 AM
Krish
Krish - avatar
+ 4
21st Feb 2021, 3:17 AM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 4
Krish [less active] i meant by inspecting the site
21st Feb 2021, 3:20 AM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 3
Thanks Abhay , do you know how to print other info too? :) Is it Always the same structure, data.userDetails....? Thanks a lot Abhay :)
20th Feb 2021, 2:05 PM
Matthew
Matthew - avatar
+ 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
20th Feb 2021, 1:58 PM
Abhay
Abhay - avatar
+ 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) }
20th Feb 2021, 2:05 PM
Abhay
Abhay - avatar
+ 2
Major data.userDetails.level and data.userDetails.bio
20th Feb 2021, 2:10 PM
Abhay
Abhay - avatar
+ 2
🔥💥holyboi💥🔥 you can create your own question or only dm Arnav. Because this is a bit offtopic now. Thanks :)
21st Feb 2021, 1:57 PM
Matthew
Matthew - avatar
+ 2
🔥💥holyboi💥🔥 thanks but I think they used api v.1, but now it doesn't work because of the new update. Btw thanks :)
21st Feb 2021, 2:19 PM
Matthew
Matthew - avatar
+ 2
Lisa Larry you can create your own question. Because this is a bit offtopic now. Thanks :)
22nd Feb 2021, 12:06 PM
Matthew
Matthew - avatar
+ 1
What do you want the data for? Just wondering...
20th Feb 2021, 7:51 PM
StephBill
StephBill - avatar
0
pls who can help me am new
22nd Feb 2021, 12:03 PM
Lisa Larry