Instant GraphQL APIs on Tinybird Pipes

Instant GraphQL APIs on Tinybird Pipes

Tinybird is a modern realtime data platform designed specifically for data engineers. It empowers data teams to effortlessly ingest streaming & batch data, develop data products using standard SQL, and publish the results as high-concurrency, low-latency HTTP APIs.

In this guide, we'll transform Tinybird's OpenAPI schema into GraphQL using the Grafbase Edge Gateway and @openapi connector.

Youtube video thumbnail

You'll want to make sure you have some Data Sources and Pipes configured before you continue with the rest of this guide.

Here's the data flow of the example workspace I created when joining Tinybird.

Tinybird Data Flow

In Tinybird, open your API Endpoint page for a Pipe then click View API:

Tinybird View API

Next click Share docs:

Tinybird Share docs

Now click OpenAPI 3.0 and copy the URL:

Tinybird OpenAPI 3.0

Inside of a new or existing project directory, run the following:

npx grafbase init --template openapi-tinybird

Now open grafbase/.env and provide the environment variables you obtained in the steps above:

# TINYBIRD_API_URL is the URL for your published API Endpoint TINYBIRD_API_URL= # TINYBIRD_API_TOKEN is the Auth Token with READ access to the API Endpoint TINYBIRD_API_TOKEN= # TINYBIRD_API_SCHEMA is the OpenAPI 3.0 spec URL copied from the API Endpoint docs page TINYBIRD_API_SCHEMA=

Now you're ready to use the Grafbase CLI to start the development server:

npx grafbase dev

That's it! You're now ready to execute Tinybird queries with GraphQL.

Open Pathfinder and you should now see the generated GraphQL queries that are named after your Tinybird Pipes:

Tinybird GraphQL queries

Let's finish by executing the following GraphQL query:

{ tinybird { topPages { data { hits visits } rows } } }

Make sure to replace topPages with the name of your Tinybird pipe.

Get Started

Build your API of the future now.