Python - how do I loop through API response to get properties values

Hey - im using python but im unable to loop through my API response. Im using the search api and the api response looks something like this. What I need are the values of the properties. Basically I need the firstname and hs_object_id of each user. I have also tried this out on my own but the last line (print(i)) only gives me the words of the properties

api_response = client.crm.contacts.search_api.do_search(public_object_search_request=public_object_search_request)
 for data in api_response._results:
 for i in data._properties:
 print(i)​
{'paging': None,
 'results': [{'archived': False,
 'archived_at': None,
 'created_at': datetime.datetime(2024, 3, 27, 9, 13, 6, 633000, tzinfo=tzutc()),
 'id': '1111',
 'properties': {'createdate': '2024-03-27T09:13:06.633Z',
 'firstname': 'Name1',
 'hs_object_id': '1111'},
 'properties_with_history': None,
 'updated_at': datetime.datetime(2024, 4, 25, 5, 33, 40, 551000, tzinfo=tzutc())},
 {'archived': False,
 'archived_at': None,
 'created_at': datetime.datetime(2024, 2, 26, 7, 31, 57, 197000, tzinfo=tzutc()),
 'id': '1112',
 'properties': {'createdate': '2024-02-26T07:31:57.197Z',
 'firstname': 'Name2',
 'hs_object_id': '1112',
 },
 'properties_with_history': None,
 'updated_at': datetime.datetime(2024, 4, 25, 7, 19, 58, 332000, tzinfo=tzutc())},

Hi, @KSingh42 :waving_hand: I know enough to be dangerous, but I am not an expert by any means. Have you tried using the get method?

Something like

api_response = client.crm.contacts.search_api.do_search(public_object_search_request=public_object_search_request)
for data in api_response._results:
 properties = data.get('properties', {})
 firstname = properties.get('firstname')
 hs_object_id = properties.get('hs_object_id')
 print(f'Firstname: {firstname}, HS Object ID: {hs_object_id}')

Best,

Jaycee