API Mocking for Mobile Development
Cloud-hosted mock APIs that work on real devices, simulators, and CI builds.
Mobile apps can't hit localhost. You need real URLs that work on physical devices, simulators, and CI servers. MockStation provides cloud-hosted endpoints that work everywhere.
The localhost Problem
Web developers can run a mock server on localhost. Mobile developers can't:
- Physical devices can't reach your computer's localhost
- iOS simulators need special configuration
- Android emulators use 10.0.2.2 instead of localhost
- CI builds run on different machines
- Team members each need their own setup
Common Workarounds (And Their Problems)
- ngrok tunnels: URLs change, free tier limits, security concerns
- Port forwarding: Complex setup, firewall issues
- Deploy to staging: Slow iteration, may not exist yet
The Solution: Cloud-Hosted Mocks
MockStation gives you stable, public URLs that work everywhere:
Real Devices
Test on physical phones and tablets
Stable URLs
Same URL works everywhere, always
No Tunneling
No ngrok, no port forwarding
Team Sharing
Everyone uses the same endpoints
React Native Example
// Works on iOS, Android, simulators, and CI
const API_BASE = __DEV__
? 'https://api.mockstation.io/v1/my-app'
: 'https://api.mycompany.com';
export const fetchUsers = async () => {
const response = await fetch(`${API_BASE}/users`);
return response.json();
};Flutter Example
class ApiConfig {
static const bool isDev = bool.fromEnvironment('dart.vm.product') == false;
static String get baseUrl => isDev
? 'https://api.mockstation.io/v1/my-flutter-app'
: 'https://api.mycompany.com';
}
// Usage
final response = await http.get(
Uri.parse('${ApiConfig.baseUrl}/products')
);Swift/iOS Example
struct APIConfig {
#if DEBUG
static let baseURL = "https://api.mockstation.io/v1/my-ios-app"
#else
static let baseURL = "https://api.mycompany.com"
#endif
}
func fetchUsers() async throws -> [User] {
let url = URL(string: "\(APIConfig.baseURL)/users")!
let (data, _) = try await URLSession.shared.data(from: url)
return try JSONDecoder().decode([User].self, from: data)
}Testing on Real Devices
With MockStation, testing on real devices is straightforward:
- Build your app pointing to MockStation URLs
- Install on your iPhone/Android device
- App works immediately no special network config
Test on your phone during your commute. Demo to clients on their devices. No laptop required.
CI/CD for Mobile
MockStation URLs work in CI environments too:
- Bitrise: Set environment variable to mock URL
- GitHub Actions: Same mock URL as local development
- Fastlane: Configure for debug builds
- App Center: Test builds use mock backend
Your test suite runs against the same stable mock, whether locally or in CI.
Offline Development
While MockStation is cloud-hosted, you can:
- Cache responses for offline testing
- Use recorded responses in your test suite
- Combine with local caching layers
Get Started
Set up mock APIs for your mobile app:
- Create a free account
- Create a project for your mobile app
- Add endpoints with realistic data
- Use the mock URL in your app config
- Test on any device instantly
Start Mobile Development Today
Create mock APIs accessible from any iOS or Android device.