Skip to main content

Export Patient Data to your CRM

Welcome to the Semble GraphQL API how-to guide. In this guide, we will show you how to use the Semble GraphQL public API to export data from Semble and maintain a live data feed of patient emails for your marketing. This process will ensure you're always working with the most recent data.

Step 1: Set Up Your API Call

The query you will be using is the patients query. This query allows you to fetch a list of patients, with customisation options to specify the data you are interested in.

Here's the basic structure of the query:

query patients(
$search: String,
$pagination: Pagination,
$options: QueryOptions
): PatientData

You need to replace $search, $pagination, and $options with the variables that fit your needs.

Step 2: Define Query Variables

In the QueryOptions, you'll want to use the updatedAt parameter to ensure you're fetching the patients that have changed since your last API call.

Here's an example of how you can set up the QueryOptions:

input QueryOptions {
updatedAt: {start: "2023-01-01T00:00:00.000z", end: "2023-01-01T23:59:59.000z"}

In this example, we are fetching the patients that were updated during a specific day. The start and end timestamps should be replaced with the appropriate time range for your needs.

Step 3: Make the API Call

Now that you have defined your query and variables, you can use your chosen method (such as cURL, JavaScript, Python, etc.) to send a POST request to the Semble API.

curl '' \
-H 'Content-Type: application/json' \
-H 'x-token: YOUR_API_TOKEN' \
-d '{
"query": "query patients($pagination: Pagination, $options: QueryOptions) { patients(pagination: $pagination, options: $options) { data { id email updatedAt } } }",
"variables": {
"pagination": {"page": 1, "pageSize": 100},
"options": {"updatedAt": {"start": "2023-01-01T00:00:00.000z", "end": "2023-01-01T23:59:59.000z"}}

Now, you're able to make the API call to Semble's GraphQL API using both JavaScript and Python to fetch updated patient data for your marketing needs.

Replace YOUR_API_TOKEN with your actual API token. This call will fetch the first 100 patients that were updated during the specified day.

Step 4: Handle the API Response

The response from the Semble API will include a list of patients, with their id, email, and updatedAt fields. You can then export this data, or feed it into your marketing system, ensuring that you always have up-to-date email addresses for your patients.

For example, this is how you would upload this data to HubSpot

First, we need to make HTTP requests to HubSpot's APIs. Below are examples of how to do this in cURL, JavaScript, and Python.

  1. You must first get your HubSpot API Key.
  2. Use this API Key to make a POST request to HubSpot's Contacts API.

The endpoint you'll be using is

The body of your request will contain the patient's email address and any other data you would like to send.

curl -X POST \
-H 'Content-Type: application/json' \
-H 'hapikey: YOUR_HUBSPOT_API_KEY' \
'' \
-d '{
"properties": [
"property": "email",
"value": ""
"property": "firstname",
"value": "John"
"property": "lastname",
"value": "Doe"

Make sure to replace 'YOUR_HUBSPOT_API_KEY' with your actual HubSpot API key and adjust the property values in the data payload to match the patient information obtained from Semble's API.

Remember to store the timestamp of your most recent API call, so that for the next call, you can set the updatedAt field to fetch only the patients updated since your last call.

By following these steps, you can create a live data feed of patient emails for your marketing purposes, ensuring you're always working with the most up-to-date information.