---
title: Making Public API Calls Using Assette Data Blocks
description: This tutorial walks through the steps required to connect to a public endpoint using Assette Interface Data Blocks to make an API Call. For the purposes of this tutorial, we will be using the REST Countries API. Additional documentation of…
url: "https://learn.assette.com/docs/making-public-api-calls-using-assette-data-blocks/"
updated: "2024-08-20"
category: Developers / Tutorials / Data Block Tutorials
tags:
  - API
  - Data Block
---

# Making Public API Calls Using Assette Data Blocks

This tutorial walks through the steps required to connect to a public endpoint using Assette Interface Data Blocks to make an API Call. For the purposes of this tutorial, we will be using the REST Countries API. Additional documentation of the REST Countries API can be found on the official [REST Countries](https://restcountries.com/) website.

## About Public APIs

Public APIs may also be called external or open APIs. These APIs are available for anyone to use with little to no restriction. In general, the primary purpose of a public API is to make information available to the public. For the purposes of this tutorial, we will be using the REST Countries API. Additional documentation of the REST Countries API can be found on the official [REST Countries](https://restcountries.com/) website.

## Connecting to a Public Endpoint

**Prerequisites**

1. Access to an Assette
2. User has "Data Block Viewer" and "Data Block Editor" roles assigned
3. Basic understanding of APIs
4. Basic understanding of Assette Data Blocks

Firstly, navigate to the Data Block Editor, which is found in the Developer Center. If you are unfamiliar with the Developer Center or Data Blocks, it is highly recommended to first read through the relevant sections on the [Data Block Editor](https://learn.assette.com/docs/data-objects-editor-overview/).

![Making Public API Calls Using Assette Data Blocks 1](https://learn.assette.com/wp-content/uploads/2024/08/image-30-1024x490.png)

In the Data Block Editor, click on the "Create New" button on the upper right-hand side of the screen.

![Making Public API Calls Using Assette Data Blocks 2](https://learn.assette.com/wp-content/uploads/2024/08/image-29-1024x232.png)

On the General Info screen, give a name to the new Data Block, and assign the fields as shown below. A more detailed explanation of each field can be found in the respective sections of the [Data Block Editor Overview](https://learn.assette.com/docs/data-objects-editor-overview/)and [Creating & Editing Data Blocks](https://learn.assette.com/docs/creating-editing-data-blocks/) articles.

| Field | Value |
| --- | --- |
| Name* | Use any letters (upper/lowercase), numbers, hyphens or underscores |
| Block Category* | Interface |
| Block Type* | API Call |
| Output Type* | None or Data Table |
| Data Category | Select any, or leave blank |
| Description | Use any letters (upper/lowercase), numbers, hyphens or underscores |

*Denotes a mandatory field.

![Making Public API Calls Using Assette Data Blocks 3](https://learn.assette.com/wp-content/uploads/2024/08/image-32-1024x347.png)

Once the General Info section has been filled out, click on the "Definition" tab. On the definition tab, enter the following code block.

```
# This API request sends a GET request to the REST Countries API and retrieves data for all countries. The "jsonpath_for_data" parameter is set to retrieve the data for the first country in the response.

{
     "baseUrl": "https://restcountries.com/v3.1/all",
     "method": "GET",
     "jsonpath_for_data": "$[0]"
}
```

![Making Public API Calls Using Assette Data Blocks 4](https://learn.assette.com/wp-content/uploads/2024/08/image-34-1024x359.png)

If you have elected to select "Data Table" as the Data Output type on the General Info tab, you can optionally select "Basic HTTP" from the template dropdown, though doing so override the current definition of the Data Block. This would normally be used when building a new Data Block API Interface and need a starting template. It is OK to leave this field as "None" or blank.

![Making Public API Calls Using Assette Data Blocks 5](https://learn.assette.com/wp-content/uploads/2024/08/image-33-1024x333.png)

To preview of the Data Block, the Data Block must first be saved (you do not need to publish). Click the "Save" button in the upper right-hand side of the screen. The Metadata, Dependencies, and Versions tabs can be left as they are.

![Making Public API Calls Using Assette Data Blocks 6](https://learn.assette.com/wp-content/uploads/2024/08/image-35-1024x359.png)

After clicking the "Save" button, click on the Preview tab, and select "Preview" in the upper right-hand corner to test the Data Block.

## Troubleshooting

| Symptom | Resolution |
| --- | --- |
| Preview button is not enabled/Cannot Preview Data Block | Save the data block. Refresh the page |
| Changes don't seem to have effect | Save the data block. Always save after making a change to ensure the latest version is used |
| Received error message when previewing | Ensure that the code block was copied correctly, including open/close curly brackets "{}" |

For additional documentation of the REST Countries public API, please consult the official [REST Countries](https://restcountries.com/) website.
