Skip to main content
Creating and using data sources

Learn how to set and use (remote) data sources in your application.

Updated over 2 months ago

What is data source feature?

This article explains how to work with the data sources feature to establish connections with external data resources for applications built on Betty Blocks. Using this feature, you can integrate data, enhancing the information available in your application.

Connections, known as application programming interfaces (APIs), facilitate communication between systems. APIs are frequently employed to update application data; for instance, when you click the refresh button on a social media app, an API connects to retrieve the latest updates, making sure you receive current information.

The article will be of interest if you are building an application that includes data sourced from the Betty Blocks platform and other external sources. Also, it assumes that you are familiar with Models and Pages for incorporating data in your application's user interface.

The following protocols are supported:

  • Open API/Swagger - a set of open-source tools built around the OpenAPI Specification that can help you design, build, document, and consume REST APIs. For more information, please see the Swagger website (https://swagger.io/)

  • Open Data Protocol (OData) Version 2 and Version 4. OData is an ISO/IEC-approved OASIS standard. For more information, see the OData website (https://www.odata.org/)

What is required for connecting to remote sources?

The following details the restrictions around the usage of the remote data source models. The remote data source feature is primarily intended for loading and showing remote data in Pages. The following details what is NOT supported:

  • Remote model permissions: the remote data source manages data authorization.

  • Authentication is currently limited to API keys.

  • The following are outside the scope of support for this feature:

    • Creating associations between regular local models and/or remote models.

    • Creating an association between remote models.

    • Creating remote models that have files and images as properties.

The following details API-specific limitations regarding support:

OData

OpenAPI (Swagger)

Limited support only is provided for OData, Version 4. Support is limited to:

  • Adding models and properties. Additional features are not currently offered.

  • Using the first metadata schema encountered as the basis for the remote data source.

While additional schemas inside a single metadata document are possible, these are not currently included in this feature.

The following return data is not supported:

  • Freeform data, also known as ‘object’. Example: “data” is an object {“data”: {“test”: 123}}.

  • An array of types. Example: “data” is an array with text properties {“data”: [“test”, “another”]}.

  • Multiple types on one property. Example: “test” can be a text or a number property {test: 1},{test: “testing”}.

How do I create a new data source?

You can incorporate data from systems outside the Betty Blocks platform. Data can be incorporated into your application to provide the details needed for supporting business needs. Once you have identified the required data, you can create a connection over an application programming interface that mirrors the specific information in your application.

Let's create a new data source from scratch using a test API resource from Typicode.

New data source

  1. Click on the Models button in the builder bar and select the Models overview in the quick menu. The model list is opened containing the Data sources feature. Fill in the following:

  • Name of the data source - for example, SAP Hana

  • URL location for obtaining the schema description (metadata) based on the data source.

2. Press Connect. If the URL is valid and contains a pre-configured data source, you'll get the approval message (✔) meaning that the connection was established. Where already available, you can select an application configuration so that the API key and the Host are dynamically configured.

Note: A list of schema models is likely to be created along with a new data source but we won't cover working with those in this particular setup.

Creating a remote model

Now that you have created a connection to the data source, you can add one or more remote models to your Models. Remote models and native models play the same role in mapping data to your application.

  1. To start adding remote models, go to New model > Remote model, or click Create your first remote model in case there were not a single model in your application.

  2. Select a newly added data source (Test API, in our example) and see the list of Available models.

  3. You can pick up the remote model you need and it will be displayed in Selected model list on the right, where you can also rename it.

Adding properties to a remote model

Note that you can add your own properties if the model from the remote data source is missing it. You can also delete and update the properties of remote data sources, meaning you can fine-tune the models precisely to your own preference.

For example, since we have Post model here (like the one you'd use for social media channels), it makes sense to add an Image property that it's currently missing.

Remote model actions

Actions tab opens the list of actions connected with a data model. A series of default actions provided with a remote data source model is displayed.

These remote model actions are auto-generated along with input variables. The rest can be configured manually.

Find out how to work with the HTTP(s) action step to request data from an external resource in Retrieving test-data with HTTP(s) step article.

We also recommend watching our video material on remote data sources:

Did this answer your question?