A mock API server or mock server API function is to imitate a real API server by providing realistic mock API responses to requests. This can be on your local machine or on the public Internet. These generated Responses can be either static or dynamic, these APIs take the requests and simulate the data which is same as the real API would return, matching the schema with data types, objects, and arrays.
Local Mock API Server
Mock API servers can be implemented either locally or externally. Local mock servers are often part of the code repository. These are built and maintained with some special tools, like webpack-dev-server, mock server, mox.
Interceptor is a similar tool option that works as a browser extension. Local mock APIs are maintained by developers because it requires technical knowledge for its maintenance and proximity to the code base. So, local mock API servers are generally maintained by developers. A few benefits of this local mock API servers are flexibility, security, and availability.
Public Mock API
Alternatively, mock APIs can also be accessed over the network and they can be separated from the development or staging environment. Therefore, an active internet connection is the basic necessity for reaching the API with client requests. External mocks are very popular because in this a team can automatically generate a mock API from an API design specification. Consequently, many services allow users to quickly create mock APIs, documentation, and software development kits (SDKs) all in one place.