All the main languages that I know off have libraries to mock API data. Usually the problem is bad API design.
I know Microsoft gets flack in HN, but I find this document a pretty good primer on API design and decisions you should make: https://docs.microsoft.com/en-us/azure/architecture/best-pra...
Now if you have to consume an API you have no control of make sure you are mocking at the right layer, aka mocking the response, not the actual call to the API.