A mock API for Flutter apps, with real authentication

Build your Flutter screens, state management and auth flow against an API that behaves like the real one, before the backend team ships it.

Free while in beta. No credit card required.

Works on every device without setup

MockLab endpoints are public HTTPS URLs. There is no local server to start, no 10.0.2.2 for the Android emulator and no cleartext HTTP exception to add, and teammates can run the app against the same mock.

What you can build before the API exists

  • Sign-in with real signed access and refresh tokens, stored with flutter_secure_storage
  • A Dio interceptor that refreshes an expired token and retries the request
  • Redirecting to the login screen when a protected endpoint returns 401
  • Paginated lists with a ?page=2 variant
  • Shimmer and retry states with a delay of up to 10 seconds or a 500 response

Call it with Dio

api_client.dart
final dio = Dio(BaseOptions(baseUrl: const String.fromEnvironment(
  'API_URL',
  defaultValue: 'https://api.mocklab.studio/mock/your-project',
)));

dio.interceptors.add(InterceptorsWrapper(
  onRequest: (options, handler) async {
    final token = await storage.read(key: 'accessToken');
    if (token != null) options.headers['Authorization'] = 'Bearer $token';
    handler.next(options);
  },
));

Switch to the real backend later with --dart-define=API_URL=https://api.yourapp.com.

Frequently asked questions

Does it work with http as well as Dio?

Yes. MockLab is a standard HTTPS JSON API, so the http package, Dio, Chopper or Retrofit all work.

Can I test token expiry?

Yes. Return {{$jwt.access:30s}} from your login endpoint and protected endpoints will reject the token after 30 seconds with a "Token Expired" error.

Does it work offline?

No. MockLab is hosted, so the device needs an internet connection.

Is MockLab free?

Yes, MockLab is free while it is in beta. No credit card required.

Stop waiting on the backend

Create your first endpoint in under a minute. It's live at a public URL as soon as you save it.

More ways to use MockLab