Skip to main content

Navigation

  • Client impact
  • Writing

AI Solutions

  • AI Systems
  • AI Development

Software teams

  • Design Systems
  • Product Design & Engineering
  • API Platforms
  • View all services for software teams
Get in touch
  • AI Systems

    Model-agnostic AI systems and agents that do real work

    AI Development

    Custom apps and tools built with AI-enabled engineering

  • Design Systems

    Depth of experience that few can match

    Product Design & Engineering

    Experts in cross-functional collaboration

    API Platforms

    Node.js, React, & GraphQL at scale


    View all services for software teams
  • Client impact
  • Writing
  • Contact

Method / Playbook · 3 min read

Mock API

Mock APIs imitate a real API by providing a realistic mock data response upon request. It’s useful during development and testing when live data is either unavailable or unreliable

Prep time: 1-2 days · Duration: 1-2 weeks · Participants: 1-2

Introduction

A mock API is designed to imitate a real API by providing a realistic mock data response upon request. A well designed mock API will reliably respond to requests with static or dynamic data that matches the real API schema including data types, objects and arrays.

Why Mock the API?

A mock API server is useful during development and testing when live data is either unavailable or unreliable. Whilst co-designing the production API, the development team can use a mock API to unblock concurrent work on the frontend and backend, and to gather feedback in user research, testing, and in stakeholder playbacks.

During development the frontend team will likely move a lot faster than the backend team can implement the real API. A mock API overcomes this issue as the frontend can consume a working API with the same interface as the eventual production API. As an added benefit, the backend team can discover where the mock API doesn’t meet the developer’s needs without spending dev time on features that may be removed or changed. We’ve found this fast feedback loop makes engineering teams much more efficient.

A mock API is also useful when unit testing. Usually our tests will run alongside a deployment, and waiting for calls to a live API is inefficient. A mock API server can return anticipated results so we can unit test the rest of the codebase without delays or reliance on an external resource.

The value of maintaining an API Specification

The mock and production APIs often evolve over time as shared understanding emerges throughout the project. To ensure that API servers are kept up to date, we’ve found it really helps to maintain a detailed API specification.

At Thinkmill this specification forms the blueprint for the API, and frontend and backend developers view it as an agreed upon contract as to how the application and API layers will communicate. We assume that if it’s not in the specification, it doesn’t exist.

While writing and maintaining specs aren’t a lot of fun, luckily there are tools that make it much less of a chore. For REST APIs the tool to use is OpenAPI Specification (Swagger), essentially a YAML file that details each endpoint and its response.

Participants

We’ve found that the creation of a Mock API is best led by a Technical Architect as they’re the person most capable of obtaining a detailed view on how the project’s underling API will need to be structured.

It’s often a good idea to include a Design Lead or UX Designer in support to help inform how the data structures might overlap with any pre-existing mental models that the users and business might hold.

The API specifications can play a valuable role for designers/product owners when sparring on features. Being able to understand the available data sources, and including references to the data types helps the team make informed design decisions that benefit both user experience and application performance.

How to setup a Mock API server

For step-by-step instructions on how to setup a Mock API using Storybook and Mock Service Worker, see our article Storybook and Mock APIs: A Powerful Prototyping Combo.

Chat to the following people to learn more about this play:

Ben Derham avatarBen Derham avatar
Ben Derham

Software Engineer. Helping teams solve tricky problems. Will stop to pat your dog.

Get playbook updates

For updates on future playbook publications, subscribe to our newsletter.

Related plays

  • Core concepts

    Core concepts are an expression of a project‘s underlying data model and relationships, translated into a written format that the team can build an aligned understanding on.

    October 2024·4 min read
  • Process mapping

    Process mapping surfaces the movement of information and user interaction throughout a system in the form of a flowchart. It captures assumptions or current-state realities related to how the system works, and helps expedite alignment, design, and development,

    October 2024·2 min read

We’d love to work with you

Get in touch

Footer

Thinkmill is a member of the Tech Council of Australia(opens in new tab).

AI Solutions

  • AI Systems
  • AI Development

Software teams

  • Design Systems
  • Product Design & Engineering
  • API Platforms
  • View all software teams

Client impact

  • ELMO
  • Tiimely
  • Atlassian
  • Reckon
  • AnywhereWorks
  • View all client impact

Open Source

  • Keystone (opens in new tab)
  • Keystatic (opens in new tab)
  • React Select (opens in new tab)
  • Classnames (opens in new tab)
  • Manypkg (opens in new tab)
  • Changesets (opens in new tab)