First things first, don't call your variable dict as that is the name of the Python type of a dictionary, so you're currently overwriting that function.
Let's call it d instead.
d = {
'total': 2,
'page': 0,
'pageSize': 10,
'count': 2,
'results': [
{'id': 3, 'domainId': 1}
]
}
Here we can see that d['results'] is what we want to query for the id. It's a list, so I would question whether you're always going to want the first thing or all of the things or just the last thing.
If it were me, I would first extract all ids, and then get the one I actually wanted.
We can get all ids as a list with:
[r['id'] for r in d['results'] if 'id' in r]
That means that if results was the following list, we'd get the following ids:
d['results'] == [
{'id': 3, 'domainId': 1},
{'id': 4},
{'domainId': 2},
{'giraffe': True}
]
ids = [r['id'] for r in d['results'] if 'id' in r]
ids == [3, 4]
At this point we could process all ids, or just get the first (ids[0]) or the last (ids[-1]).
If you know exactly which index it's going to be in results, you could access that directly.
d['results'][-1]['id']