Skip to main content
Matik Help Center home page Help Center
Matik Blog Case Studies
  1. Matik
  2. Building Templates
  3. Dynamic Content

Using a Rest API as a Dynamic Content Data Source

Setting up Rest API Dynamic Content

  1. Create a Rest API datasource
  2. Create a new piece of Dynamic Content and select your data source
  3. Select your API HTTP Method (GET or POST)
  4. Enter your API URL
    • Matik inputs can be used in the query parameters of the API URL to customize the API call. Entering &:<Input_name> will replace text in the URL with input values.
  5. (POST only) Enter your request body text.
    • Matik inputs can be used to customize the API request body. Entering &:<Input_name> will replace text in the URL with input values.
  6. Test. Click on Test API to retrieve a test result.

Formatting API Results

API calls typically return a JSON string.

To get a single value or table from these results additional formatting is needed. Matik utilizes the JQ filtering language to define columns needed from the return JSONs. Matik will only include data specified in the Format Results section of the dynamic content section.

To specific the data from your results json to be formatted and returned, enter a column name (user defined) in the Column Name section of Format Results. In the Result Source section enter the relevant JQ Command to extract that column. For example, if I want to extract the sunrise column from the JSON above, my Format Results would look like the following: 

Click on the + Icon to add additional columns to your results table.

Formatting Multiple Row Results in an Array

Often times multiple rows of results will be returned in an array form. In JQ we can access each object as a row using the following notation: .results[].<key> Note that if only an array of jsons is returned we can access the elements with just .[].<key>

For example, if we want the "subject" column of this array:

{
    "results": [
        {
            "classid": 1,
            "level": "101",
            "subject": "French 1",
            "department": "Languages",
            "alt_subject": "Français 1",
            "_id": {
                "$oid": "60494d26917b337f4a9ca774"
            }
        },
        {
            "classid": 2,
            "level": "101",
            "subject": "Algebra 1",
            "department": "Mathematics",
            "_id": {
                "$oid": "60494e4a917b337f4a9ca775"
            }
        }

    ],
    "hasMore": true,
    "responseTime": 17
}

We can enter it in Matik as:

Which will return:

Subject
__________
French 1
Algebra 1

 

ChatGPT is very good at taking an example JSON returned from an API call and telling you the proper JQ command to extract the data you want:
"How do I extract a table from the following json using JQ: {json}

Was this article helpful?

Have more questions? Submit a request

Related articles

  • Connecting to Rest APIs
  • Matik App for Salesforce Setup
  • Adding Matik Users
  • Tags Overview
  • Dynamic Content Overview

Articles in this section

  • Using Gainsight in Dynamic Content
  • Using Chart Dynamic Content with Google Sheets in Slides Templates
  • Dynamic Content Overview
  • Working with Images in Dynamic Content
  • Using Matik Insights Dynamic Content
  • Using Excel with Matik
  • AI Descriptions
  • Rich Text Formatting
  • Using HubSpot in Dynamic Content
  • Using Matik Logos as a Dynamic Content Data Source
  • See all articles

Comments

0 comments

Please sign in to leave a comment.

Personalize data-driven content in minutes

Product

  • How it Works
  • Integrations
  • AI Features
  • Security

Solutions

  • Sales
  • Customer Success
  • Ops & Strategy
  • Data

Resources

  • Blog
  • Templates
  • AI + CS Resource Hub
  • Case Studies
  • Help Center

Company

  • About Us
  • Careers
  • Terms of Service
  • Privacy Policy

© 2024 Matik, Inc.