Skip to main content

Making Your First Requests

Welcome to the Quick Start Guide for the Semble GraphQL Public API. This guide will help you make your first GraphQL requests to our API by showcasing practical examples in cURL, JavaScript, and Python.

Step 1: Setup

Before you can send requests, you'll need to set up your environment:

  1. Install cURL, a widely-used command-line tool for sending HTTP requests.

  2. If you're using JavaScript, make sure you have node-fetch installed. Use npm install node-fetch if not.

  3. For Python users, ensure you have the requests library. If it's not installed, you can add it with pip install requests.

  4. Obtain an authentication token:

    • For token authentication, generate a token in the Semble application's settings section.

Step 2: Fetching Patient Data

We're going to make a request to the patient query to fetch a patient's firstName and email.

curl -X POST https://open.semble.io/graphql \
-H "Content-Type: application/json" \
-H "x-token: yourtoken" \
-d '{
"query": "query { patient(id: \"1\") { firstName email } }"
}'

Replace yourtoken and id with your actual token and patient ID.

Step 3: Adding a Label to a Patient

Next, we're going to add a label to a patient using the addPatientLabel mutation. The mutation takes two parameters: patientId and labelReferenceId.

curl -X POST https://open.semble.io/graphql \
-H "Content-Type: application/json" \
-H "x-token: yourtoken" \
-d '{
"query": "mutation addPatientLabel($patientId: ID!, $labelReferenceId: ID!) { addPatientLabel(patientId: $patientId, labelReferenceId: $labelReferenceId) { data { id } error } }",
"variables": {"patientId": "1", "labelReferenceId": "1"}
}'

Replace yourtoken, patientId, and labelReferenceId with your actual token, patient ID, and label reference ID.

Step 4: Exploring Further

Congratulations on making your first requests to the Semble GraphQL Public API! Once you're comfortable with these basics, feel free to explore more complex queries and mutations. The Semble GraphQL Public API provides a rich set of features that can help you build robust and efficient applications.

Remember to refer to our detailed API Reference section for comprehensive information about all available queries, mutations, and subscriptions.

Troubleshooting

If you encounter any issues, please reach out to our integrations team. Happy coding!