Parsing an API Response

Last updated on March 29, 2023.

This guide discusses how to parse an API response.

In this example, you will store part of the response in a Database Field for later reference using GraphQL mutations in , since you can access the response body via .

The tutorial assumes the API returns JSON like:

It is also assumes that you want to store the value (which is ).

Prerequisites

To follow the steps in this tutorial, you must understand the concept of Users and Database Fields. It is assumed that you have already created the User Profile and API Call Notification in the previous tutorials.

Steps

Parsing an API response is a four-step process:

  • Step 1: Create a Database Field (Property)
  • Step 2: Add a GraphQL mutation
  • Step 3: Create a Form
  • Step 4: Extend the API Call Notification with a callback

Step 1: Create a Database Field (Property)

As a first step, create a Property in the user profile. In this example, you will use .

Step 2: Add a GraphQL mutation

Add GraphQL mutation:

app/graphql/store_third_party_api_id.graphql

Step 3: Create a Form

The mutation you created provides input for the Form called , so create this Form:

app/forms/callback_third_party_api_id.liquid

Step 4: Extend the API Call Notification with a callback

Extend the API Call Notification by adding the proper callback, which executes the mutation with the input received from the third-party API:

app/api_calls/ping_example_com_on_user_sign_up.liquid

Have a suggestion for this page?

Didn't quite find what you are looking for or have feedback on how we can make the content better then we would love to hear from you. Please provide us feedback and we will get back to you shortly.