Course overview
Lesson 4 of 8 · 3 promptsAI for Mobile App Developers
LESSON 04 OF 8

Draft a Networking Layer

3 prompts for Mobile App Developers

Prompts for Mobile App Developers: copy one, fill it in, paste it into your AI.

Track progress as a member

In this lesson

  1. 01Draft a Mobile App Networking LayerUse this when you need a clean API client with requests, models, and error handling for a mobile app.
  2. 02Map API Errors to User MessagesUse this when you want to map API status codes and network failures to clear, user-friendly messages in a mobile app.
  3. 03Mock Realistic API Response FixturesUse this when the backend endpoints are not ready and you need believable sample API data to build and test your app screens.
1Copy the promptClick Copy on the prompt you need.
2Paste it into your AIChatGPT, Claude, Gemini or Copilot.
3Fill in the {{brackets}}Your own details, or let the AI ask you.
4Follow up and checkUse the follow-ups, then check the facts.
01

Draft a Mobile App Networking Layer

Use this when you need a clean API client with requests, models, and error handling for a mobile app.

Prompt

Role You are a senior mobile engineer who writes clean, testable networking layers for iOS and Android apps. Optimise for a small, predictable API client that other developers can extend without rewriting.

Context you provide

  • {{platform}} - iOS, Android, or both
  • {{language_framework}} - e.g. Swift with URLSession, Kotlin with Retrofit
  • {{api_base_url}} - base URL for the API
  • {{endpoints_list}} - endpoints, HTTP methods, and expected responses
  • {{auth_method}} - token, API key, or session cookie
  • {{model_shape}} - fields and types for each response model
  • {{error_requirements}} - how errors should be surfaced to callers
  • {{caching_needs}} - offline or cache rules, if any
  • {{testing_framework}} - test runner and mocking approach
  • {{project_conventions}} - naming, folder layout, and style rules

Instructions

  1. Ask for any missing inputs, then restate the goal in one sentence.
  2. Propose a folder and file layout for the networking layer.
  3. Define request and response models from {{model_shape}}.
  4. Write the API client with one method per endpoint, using {{auth_method}}.
  5. Add error handling that maps transport, HTTP, and decoding failures into typed errors.
  6. Add caching or offline behaviour only if {{caching_needs}} requires it.
  7. Include unit tests using {{testing_framework}} with mocked responses.
  8. List assumptions and anything a reviewer must confirm.

Output format Markdown with one heading per file, code blocks tagged with the language, and a short usage example. Keep comments minimal. No hype, no em dashes.

Guardrails

  • Do not invent endpoint paths, response fields, or auth details. Ask for them instead.
  • Flag every assumption about the API contract and mark it clearly.
  • Tell the user to check the platform's official documentation and the API provider's spec before shipping.

Example Platform: iOS and Android; Framework: Swift URLSession and Kotlin Retrofit; Base URL: https://api.example.com/v1; Endpoints: GET /users, POST /sessions; Auth: bearer token.

Open as its own page

02

Map API Errors to User Messages

Use this when you want to map API status codes and network failures to clear, user-friendly messages in a mobile app.

Prompt

Role: You are a mobile app developer who turns API status codes and network failures into clear, user-friendly messages that keep users oriented and reduce support tickets. Optimise for accurate recovery paths, not technical detail.

Context you provide:

  • {{platform_and_framework}}: e.g., SwiftUI, Jetpack Compose, React Native
  • {{api_spec_or_endpoints}}: endpoints plus status codes you handle
  • {{known_failure_modes}}: timeouts, offline, rate limits, validation errors
  • {{existing_error_handling}}: current pattern or code, if any
  • {{brand_tone}}: voice, formality, emoji policy
  • {{screen_or_journey}}: where the error appears

Instructions:

  1. Ask for any missing inputs, then confirm the platform and API surface.
  2. Build a mapping table: each code or failure condition, its plain-language cause, who is responsible (user, server, network), and whether retry is possible.
  3. Write one user-facing message per row. Keep it specific, calm, and actionable. No status codes or internal terms in the message.
  4. Assign a recovery action: retry, edit input, sign in again, contact support, or continue offline.
  5. Give a small code example for a central error mapper and fallback UI on the stated platform.
  6. Cover edge cases: offline, slow network, partial success, expired session, maintenance.

Output format: Markdown. One table: Condition or code | Cause in plain language | User message | Recovery action. Then a code block for the mapper. Then a short bullet list of edge cases. Under 800 words. Tone: practical and direct.

Guardrails:

  • Do not invent status codes, error codes, or API behaviour. Flag missing cases as assumptions.
  • Never expose stack traces, server names, or internal identifiers in user-facing copy.
  • If the flow involves payments, authentication, or personal data, tell the user to check platform review guidelines and their security or legal team.

Example: Platform: React Native; API: /login returns 401, 429, 500; failure modes: offline, timeout; brand tone: friendly and brief; journey: sign-in screen.

Open as its own page

03

Mock Realistic API Response Fixtures

Use this when the backend endpoints are not ready and you need believable sample API data to build and test your app screens.

Prompt

Role You are a mobile API integration assistant. You produce realistic mock API responses so an app developer can build and test screens before the backend exists, with fixtures that drop in without rework.

Context you provide

  • {{platform_and_http_layer}} - e.g. Swift with URLSession, Kotlin with Retrofit
  • {{endpoint}} - HTTP method and path
  • {{response_fields}} - field names, types, nullability
  • {{record_count}} - records per page and total pages
  • {{error_cases}} - status codes and failure states to cover
  • {{locale_and_dates}} - date format, timezone, currency
  • {{mock_tool}} - JSON file, Mockoon, WireMock, MSW, or inline stub

Instructions

  1. Ask for any missing inputs, then generate the fixtures.
  2. Match {{response_fields}} exactly: same names, types, nesting. Do not add fields unless you flag them.
  3. Produce a full page, a short final page, and an empty page for {{record_count}}.
  4. Vary values plausibly across records and keep them internally consistent.
  5. Add one payload per {{error_cases}} entry, plus a slow or timed out response.
  6. Give a short wiring snippet for {{mock_tool}} in {{platform_and_http_layer}}, including how to switch the base URL.

Output format JSON code blocks first, a one-line note per fixture on when it is used, then the wiring snippet. Plain tone, no commentary inside the JSON. Leave out explanations of REST basics.

Guardrails

  • Do not invent field names, status codes, or endpoints that were not supplied; ask instead.
  • Flag every assumption and note that fixtures must be reconciled with the real API contract before release.
  • Use clearly fake names, emails, and identifiers; never include real personal data.

Example GET /v1/orders, Swift with URLSession, 12 orders over 3 pages, 401 and 500 cases, JSON files in the Xcode bundle.

Open as its own page

Skills for these tasks

Give your AI these skills and it does these tasks the expert way. Connect your AI once and it picks them up by itself.