Home > Back-end >  How to fetch only one type of key values in an object in python
How to fetch only one type of key values in an object in python

Time:01-11

so here is a object which i got from Telegram API

{'ok': True, 'result': [{'update_id': 634527149, 'message': {'message_id': 2, 'from': {'id': 5060166011, 'is_bot': False, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'language_code': 'en'}, 'chat': {'id': 5060166011, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'type': 'private'}, 'date': 1641826968, 'text': 'Hi'}}, {'update_id': 634527150, 'message': {'message_id': 13, 'from': {'id': 5060166011, 'is_bot': False, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'language_code': 'en'}, 'chat': {'id': 5060166011, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'type': 'private'}, 'date': 1641827128, 'text': '/start', 'entities': [{'offset': 0, 'length': 6, 'type': 'bot_command'}]}}, {'update_id': 634527151, 'message': {'message_id': 38, 'from': {'id': 5060166011, 'is_bot': False, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'language_code': 'en'}, 'chat': {'id': 5060166011, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'type': 'private'}, 'date': 1641827383, 'text': '/start', 'entities': [{'offset': 0, 'length': 6, 'type': 'bot_command'}]}}, {'update_id': 634527152, 'message': {'message_id': 39, 'from': {'id': 5060166011, 'is_bot': False, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'language_code': 'en'}, 'chat': {'id': 5060166011, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'type': 'private'}, 'date': 1641827627, 'text': 'Hello'}}, {'update_id': 634527153, 'message': {'message_id': 79, 'from': {'id': 5060166011, 'is_bot': False, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'language_code': 'en'}, 'chat': {'id': 5060166011, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'type': 'private'}, 'date': 1641828205, 'text': '/start', 'entities': [{'offset': 0, 'length': 6, 'type': 'bot_command'}]}}, {'update_id': 634527154, 'message': {'message_id': 129, 'from': {'id': 5060166011, 'is_bot': False, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'language_code': 'en'}, 'chat': {'id': 5060166011, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'type': 'private'}, 'date': 1641837940, 'text': '/start', 'entities': [{'offset': 0, 'length': 6, 'type': 'bot_command'}]}}, {'update_id': 634527155, 'my_chat_member': {'chat': {'id': -646604598, 'title': '151 days of coding', 'type': 'group', 'all_members_are_administrators': True}, 'from': {'id': 5060166011, 'is_bot': False, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'language_code': 'en'}, 'date': 1641837952, 'old_chat_member': {'user': {'id': 5082767515, 'is_bot': True, 'first_name': 'Send To Telegram', 'username': 'SendToTelegramX_Bot'}, 'status': 'left'}, 'new_chat_member': {'user': {'id': 5082767515, 'is_bot': True, 'first_name': 'Send To Telegram', 'username': 'SendToTelegramX_Bot'}, 'status': 'member'}}}, {'update_id': 634527156, 'message': {'message_id': 130, 'from': {'id': 5060166011, 'is_bot': False, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'language_code': 'en'}, 'chat': {'id': -646604598, 'title': '151 days of coding', 'type': 'group', 'all_members_are_administrators': True}, 'date': 1641837952, 'new_chat_participant': {'id': 5082767515, 'is_bot': True, 'first_name': 'Send To Telegram', 'username': 'SendToTelegramX_Bot'}, 'new_chat_member': {'id': 5082767515, 'is_bot': True, 'first_name': 'Send To Telegram', 'username': 'SendToTelegramX_Bot'}, 'new_chat_members': [{'id': 5082767515, 'is_bot': True, 'first_name': 'Send To Telegram', 'username': 'SendToTelegramX_Bot'}]}}, {'update_id': 634527157, 'message': {'message_id': 131, 'from': {'id': 5060166011, 'is_bot': False, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'language_code': 'en'}, 'chat': {'id': -646604598, 'title': '151 days of coding', 'type': 'group', 'all_members_are_administrators': True}, 'date': 1641837967, 'text': '/start@SendToTelegramX_Bot', 'entities': [{'offset': 0, 'length': 26, 'type': 'bot_command'}]}}, {'update_id': 634527158, 'message': {'message_id': 132, 'from': {'id': 874434712, 'is_bot': False, 'first_name': '1DS18TE030', 'username': 'thekumaraswamy'}, 'chat': {'id': -646604598, 'title': '151 days of coding', 'type': 'group', 'all_members_are_administrators': True}, 'date': 1641837971, 'text': '/start@SendToTelegramX_Bot', 'entities': [{'offset': 0, 'length': 26, 'type': 'bot_command'}]}}, {'update_id': 634527159, 'message': {'message_id': 133, 'from': {'id': 874434712, 'is_bot': False, 'first_name': '1DS18TE030', 'username': 'thekumaraswamy'}, 'chat': {'id': -646604598, 'title': '151 days of coding', 'type': 'group', 'all_members_are_administrators': True}, 'date': 1641837975, 'text': '/start@SendToTelegramX_Bot', 'entities': [{'offset': 0, 'length': 26, 'type': 'bot_command'}]}}, {'update_id': 634527160, 'message': {'message_id': 134, 'from': {'id': 874434712, 'is_bot': False, 'first_name': '1DS18TE030', 'username': 'thekumaraswamy'}, 'chat': {'id': -646604598, 'title': '151 days of coding', 'type': 'group', 'all_members_are_administrators': True}, 'date': 1641838036, 'text': '/gamble', 'entities': [{'offset': 0, 'length': 7, 'type': 'bot_command'}]}}, {'update_id': 634527161, 'message': {'message_id': 140, 'from': {'id': 5060166011, 'is_bot': False, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'language_code': 'en'}, 'chat': {'id': -646604598, 'title': '151 days of coding', 'type': 'group', 'all_members_are_administrators': True}, 'date': 1641838331, 'text': '/daan 50', 'entities': [{'offset': 0, 'length': 5, 'type': 'bot_command'}]}}, {'update_id': 634527162, 'message': {'message_id': 142, 'from': {'id': 5060166011, 'is_bot': False, 'first_name': 'Mosquito', 'username': 'TheMosquitoo', 'language_code': 'en'}, 'chat': {'id': -646604598, 'title': '151 days of coding', 'type': 'group', 'all_members_are_administrators': True}, 'date': 1641838571, 'reply_to_message': {'message_id': 141, 'from': {'id': 5082767515, 'is_bot': True, 'first_name': 'Send To Telegram', 'username': 'SendToTelegramX_Bot'}, 'chat': {'id': -646604598, 'title': '151 days of coding', 'type': 'group', 'all_members_are_administrators': True}, 'date': 1641838464, 'text': 'Day 16 #100DaysOfCode #151daysofcode \n- Revised react life cycle methods\n- Started Learning more about styling using CSS.\n\n#webdevelopment #reactjs\n@NikhilRNaik2', 'entities': [{'offset': 7, 'length': 14, 'type': 'hashtag'}, {'offset': 22, 'length': 14, 'type': 'hashtag'}, {'offset': 123, 'length': 15, 'type': 'hashtag'}, {'offset': 139, 'length': 8, 'type': 'hashtag'}, {'offset': 148, 'length': 13, 'type': 'mention'}]}, 'text': 'This is the twitter bot I made Today           
  •  Tags:  
  • Related