A FOSS mock data generator for your next data project
Tags: data, analytics, productivity, opensource
Published: 2023-05-17 14:43:12

When you build a data project, you often need some source of non-production data that you can use to develop against, find edge cases, and test performance at scale.

In the batch world, it’s common to simply upload a massive CSV file, but this doesn’t work for real-time and streaming applications. You need to be able to generate a constant stream of data that emulates the real world, both in terms of data schema and generation frequency.

There are plenty of public APIs that you can use to build demo applications or stress test infrastructure if you don’t need a data stream that follows your own custom schema or timing.

Some of my favorites for demos are:

- [UK National Grid Carbon Intensity API](https://carbonintensity.org.uk/)
- [Wikipedia Recent Changes Feed](https://en.wikipedia.org/w/api.php?action=help&modules=feedrecentchanges)
- [IEX Stock Market Data Feed](https://www.iexexchange.io/products/market-data-connectivity)
- [Coinbase Crypto Market Data Feed](https://docs.cloud.coinbase.com/exchange/docs/welcome#websocket-feed)

These APIs and data sets are super helpful, and I’m grateful for those who maintain them. That said, I have no control over the schema and the data frequency, and if I’m building a project unrelated to carbon intensity, Wikipedia pages, stock markets, or crypto, these aren’t ideal. I need more control and precision. I need a mock data generator.

In Tinybird, you can ingest data from a number of different sources. Whether you’re streaming from Kafka, importing from BigQuery, or just uploading a simple CSV file, Tinybird gives you the power to capture events and dimensions from those sources, query and enrich them with SQL, and publish your queries as low-latency, parameterized HTTP APIs to power your applications.

But there are loads of reasons why you might want to use mock data. You might still be evaluating the service and don’t want to use your own data yet, or you don’t want to use real data in development environments, or perhaps you’re still building the rest of your streaming pipeline.

In that case, you need a simple, serverless tool to define both your schema and generation frequency with absolute precision.  

You need Mockingbird.

## Mockingbird: A free, open source mock data generator
We recently introduced Mockingbird, a flexible, FOSS mock data generator to stream data to any destination with an HTTP endpoint. With Mockingbird, you can define a data schema in JSON, set the data generation frequency, and start streaming mock data based on your schema to any HTTP-enabled streaming endpoint.

We originally built Mockingbird to help us create demos for Tinybird, but we understood we couldn’t be the only ones who needed a better source of mock data. So, we’ve chosen not to limit the destinations of your data to just Tinybird.

Mockingbird is free and open source, and new destinations can be added by anyone, including the community and other vendors, by creating new Destination plugins.

Currently, 5 Destinations are supported:

1. [Tinybird Events API](https://www.tinybird.co/docs/ingest/events-api.html)
2. [Upstash Kafka REST Producer API](https://docs.upstash.com/kafka/restproducer)
3. [Ably REST API](https://ably.com/docs/api/rest-api)
4. [AWS SNS](https://aws.amazon.com/sns/)
5. [Confluent Cloud ](https://www.confluent.io/confluent-cloud/)

### Headless library, CLI, or UI
Mockingbird is licensed under the Apache 2.0 license, and the source is [publicly available on GitHub](https://github.com/tinybirdco/mockingbird). It is designed to be flexible and work in a variety of different scenarios. 

To that end, it is available as a headless library, a CLI, and a UI. You can embed the library in your own custom project, use the CLI as part of a CI/CD pipeline, or interactively run ad-hoc tests from the UI.

Here are links to each of your options:

1. [Install the library with npm](https://www.npmjs.com/package/@tinybirdco/mockingbird)
2. [Install the CLI](https://www.npmjs.com/package/@tinybirdco/mockingbird-cli)
3. [Use the UI](https://mockingbird.tinybird.co) (you’re welcome to host your own, too!)

### Define your schema in JSON
With Mockingbird, you define a schema for your events in JSON. We’ve already included a whole bunch of predefined Data Types so you can generate data in just about every way imaginable, but if there’s something missing, **we welcome anyone to contribute new Data Types** to meet their needs. 

We’ve also created a library of preset schema templates for you to use, either as-is or as a starting point to customize. Again, everyone is welcome to contribute new schema templates to meet common use cases.

### Sending mock data to the Tinybird Events API
To send data to Tinybird, Mockingbird uses the Tinybird [Events API](https://www.tinybird.co/docs/guides/ingest-from-the-events-api.html), which offers a few unique advantages:

- **It’s easy**. The Events API is just an HTTP endpoint, so you don’t have to worry about any languages or client-side dependencies. Just define your JSON and issue the request. Of course, Mockingbird takes care of this for you if you choose the Events API as a destination.
- **It’s flexible**. You can send events to an existing Tinybird Data Source, or automatically generate a new one. The Events API will automatically generate a Data Source with an optimal schema based on the JSON you build.
- **It’s fast**. The Tinybird Events API can handle up to 1,000 requests per second out of the box so that you can stream large amounts of data quickly.

### Sending mock data to external Destinations
Mockingbird doesn’t just generate mock data to send to Tinybird. You can also send it to supported third-party Destinations. We currently suppor the Upstash Kafka REST Producer API, the Ably REST API, AWS SNS, and Confluent Cloud topics as alternative Destinations.

If you want to see more Destinations supported, you have two options:

- Submit an issue in the [GitHub repository](https://github.com/tinybirdco/mockingbird) for the community to consider.
- Contribute one! It’s open-source, after all.

## How to use Mockingbird to generate mock data
First, navigate to [mockingbird.tinybird.co](https://mockingbird.tinybird.co).

<figure><img src="https://global-uploads.webflow.com/604a2f667b2fcefbc095bfc8/643ee90099de84a931e8435f_mockingbird_home.jpg" loading="lazy" alt="A screenshot of Mockingbird, the FOSS mock data stream generator from Tinybird"><figcaption>We offer theMockingbird project as a hosted UI, but feel free to make it your own with the headless library.</figcaption></figure>

Next, enter your Destination settings based on your chosen Destination. If you choose Tinybird as a Destination, this will include a Data Source name (existing or new), a token with `DATASOURCE:WRITE` scope, your Workspace host, and the number of events you want to send per second.

<figure><img src="https://global-uploads.webflow.com/604a2f667b2fcefbc095bfc8/6439a1fd8f14c9eaaff6a34b_9K2fQ6_KO2fX74qsKG1v8m0-dlfGL9R8S5o2njZXHbpEZCrwPpJ09ucOVvAsNn5Q5yPSqNXlwfVng_RVUWWowCR-QH9R0hEhHSEphqTrBXz5RYNr8Sh8hWE_VWLWuPnZ-NwQNcOPu-LSuytrPz6_ZG4.jpeg" alt="A screenshot showing mock data streaming destinations in Mockingbird"><figcaption>Mockingbird allows you to stream mock data to Tinybird or to external destinations. As of this launch, Upstash Kafka is supported as an alternative Destination. Community members can easily add new Destinations to the library.</figcaption></figure>

> **NOTE**: If you haven’t created a Tinybird Workspace, you can set up your first one at [ui.tinybird.co](https://ui.tinybird.co).

Then, create your JSON schema. You can also choose from any of our pre-existing templates and either use them as is or modify them as needed. When you click Save, you’ll see a preview of the JSON payload that will be sent to the Destination.

<figure><img src="https://global-uploads.webflow.com/604a2f667b2fcefbc095bfc8/6439a1fdcc66ba269f9c6da5_rKSzemH7p5RZXd1VFx5OdLK88OGndKsPObLHvCu65ynYxn6n7IXpUqD4i7Jiv8u5Pkb0sYi2q6HS0m832YPpiMUc7dFCWwsyduU4I1j9g56rB3chlnsDPRcVa5Eq9wvijlSsNATt6QCt1iyw4dgA4Gc.jpeg" alt="A screenshot showing mock data schema generation in JSON"><figcaption>Mockingbird allows you to define a mock data schema in JSON and preview your final schema before streaming to your destination.</figcaption></figure>

When you’re happy with your schema, click Start Generating, and you’ll begin streaming events to your Destination. You’ll be able to monitor, pause, and resume your mock data streaming while it executes.

<figure><img src="https://global-uploads.webflow.com/604a2f667b2fcefbc095bfc8/6439a1fdcd68c983a268accd_9UE4Cyy1bPt2EpbamH5DoqZlHfntY7BY_XPKq1-zItv30y0zD6bVmWgRdfMuxKd41XGt8esXA4cqRsEapbqmC6rtdVjkrApkRbKqCpnwlFvJK9xCXG35sOYH2fwDD25mFilT0TyE7UJ6vbEpv-6pjek.jpeg" alt="A screenshot showing mock data being generated and streamed using Mockingbird."><figcaption>You can monitor, pause, and resume your mock data streams during your session.</figcaption></figure>

And that’s it! 

## Start streaming mock data to Tinybird
For more info on Mockingbird, [check out the docs](https://mockingbird.tinybird.co/docs). You'll find information on Data Types, Destinations, and Schema building.

If you’re not yet a Tinybird customer, you can sign up [here](https://www.tinybird.co/signup?referrer=dev.to). The Tinybird Build Plan is free forever, with no time restrictions, no credit card required, and generous limits.

Also, feel free to join the [Tinybird Community on Slack](https://www.tinybird.co/community) and ask us questions or request additional features.