Betty Blocks data API

Learn what the data API is and why it is useful for enhancing the way you collect, manipulate and manage data within Betty Blocks.

After reading this article, you’ll know the following:

  • Data API and its use

  • GraphQL tool and its features

  • How data API is different from REST API

Welcome to the Betty Blocks data API documentation. This quick guide explains the notion of data API, why it was developed, and what it offers for builders.

What is data API?

Data API is a tool designed to enhance the efficiency of data retrieval and manipulation within Betty Blocks. It builds on existing platform features to offer faster, more flexible ways of reading, mutating, and managing data, giving you complete control over the data you need.

GraphQL explained

GraphQL is the backbone of our data API - a space where developers can easily set up custom requests. GraphQL tooling offers a clear overview of all possible queries for your data. An example of use can be found in Getting started with data API.

One of the great features of Betty Blocks’ GraphQL are Docs and Explorer that are located on the left side of the interface when you provide a valid token.

  • Docs display all available queries and mutations, giving you a complete overview of the data you can request or modify

  • Explorer allows you to build queries by simply clicking on the fields you want. It’s a user-friendly way to construct queries without memorizing the GraphQL schema

Another handy aspect of the GraphQL playground is its filtering capabilities. You can quickly check and filter data, making it easy to pull the specific information you need with minimal effort. This feature is particularly useful for developers who need to test or verify data without crafting complex queries from scratch.

How does data API differ from REST API?

REST APIs function by offering predefined endpoints, each responsible for returning specific data. For example, https://api.example.com/users returns a list of all users, while https://api.example.com/user/3 returns a specific user by ID.

While this structured approach is effective, it can become tedious when dealing with numerous endpoints. GraphQL (and by extension, the data API) removes the need to remember multiple endpoints. Instead, it uses a single endpoint that accepts queries for the specific data you need, whether it’s users, invoices, or products.

Even better, GraphQL tools provide a clear overview of all possible queries, simplifying the process of building your API calls.

Where can data API be used?

Our data API primarily serves the Pages segment. Whether you’re working with the default component set or building custom components via the CLI, the data API handles data collection.

The API replaces the traditional server-side variable rendering with client-side data requests, making the platform faster and more efficient from both a backend and user experience perspective.

➝ Next article: Getting started with the Data API