Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to get someone's activity and status using their id and discord api in python and I have written some code to do that but I'm really confused about the output.


Maybe my code isn't even doing what I actually want it to do, Maybe I'm just doing this completely incorrect and the output is something way different, Any help would be appreciated.

I did see another post with something similar and the answer was this link https://discord.com/developers/docs/topics/gateway#activity-object-activity-structure now I don't understand how to like implement this since I tried and it failed supposedly the data is supposed to look like this if I implemented it: { "details": "24H RL Stream for Charity", "state": "Rocket League", "name": "Twitch", "type": 1, "url": "twitch.tv/discord" }


What I have tried:

The code:


import requests
token = 'REDACTED'
headers = {'Authorization': token}
base_URL = "https://discord.com/api/v9"
base_URL_attachment = base_URL + "/activities"
f = requests.get(base_URL_attachment, headers=headers).json()
print(f)

The output:

[{'user_id': '455082161050222595', 'application_id': '356876176465199104', 'updated_at': '2022-09-03T17:50:26.457000+00:00', 'duration': 11062}, {'user_id': '455082161050222595', 'application_id': '614454657753939987', 'updated_at': '2022-09-03T19:21:05.516000+00:00', 'duration': 74}, {'user_id': '911382588587921439', 'application_id': '356869127241072640', 'updated_at': '2022-09-03T17:08:27.673000+00:00', 'duration': 20095}, {'user_id': '911382588587921439', 'application_id': '363412841862266880', 'updated_at': '2022-09-03T21:14:12.069000+00:00', 'duration': 5399}, {'user_id': '324477408717701121', 'application_id': '363445589247131668', 'updated_at': '2022-09-02T15:28:11.245000+00:00', 'duration': 1510}, {'user_id': '237598665122775040', 'application_id': '356869127241072640', 'updated_at': '2022-09-02T08:34:11.834000+00:00', 'duration': 2818}, {'user_id': '720754227848151070', 'application_id': '356877880938070016', 'updated_at': '2022-09-03T23:01:28.132000+00:00', 'duration': 0}, {'user_id': '720754227848151070', 'application_id': '357607478105604096', 'updated_at': '2022-09-04T01:38:28.368000+00:00', 'duration': 3600}, {'user_id': '995433254595330090', 'application_id': '432980957394370572', 'updated_at': '2022-09-03T21:34:18.138000+00:00', 'duration': 594}, {'user_id': '821376098104377424', 'application_id': '363445589247131668', 'updated_at': '2022-09-03T22:02:44.429000+00:00', 'duration': 10293}]{
Posted
Updated 6-Sep-22 4:41am

1 solution

You have not explained what you want your code to do, or exactly what it does. However, I suspect the place for help on this is at https://support.discord.com/hc/en-us[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900