I've done some research and read some of the posts about this topic, but none of them are up to date.
The answer from 8 years ago says that accessing via the API does not count for badges:
The mobile app uses the API at that time, so accessing Stack Exchange sites using the mobile app also does not count for badges:
However, this issue of the mobile app seemed to be resolved in 2013:
Does this mean that now accessing via the API can count for the badges?