Make the API request

Make the API call to the Query Records endpoint of Morph REST API.

In the previous two steps* , you learned how to use the URL of Morph or Developer Mode to find the values of the teamSlug, databaseId and tableSlug.

Now, you will use these values to replace the placeholders in the URL of the Query Records endpoint of Morph REST API to make your first API call.

This section shows you how to make the API request using cURL or Postman.


📘

Previous two steps: Parameters of the request and Find teamSlug, databaseId and tableSlug


cURL

To make the HTTP request directly using cURL:

  • Open a Terminal window.
  • Replace the following placeholders in the cURL template below with your own values.
    • In the URL:
      • {YOUR_TEAM_SLUG}
      • {YOUR_DATABASE_ID}
      • {YOUR_TABLE_SLUG}
    • In the headers:
      • {YOUR_API_KEY} for the x-api-key
  • Run the command in your Terminal.

Request

The API request format with placeholders is:

curl --X POST 'https://{YOUR_TEAM_SLUG}.api.morphdb.io/v0/record/{YOUR_DATABASE_ID}/{YOUR_TABLE_SLUG}/query' \       
--header 'Content-Type: application/json' \
--header 'client-type: widget' \
--header 'x-api-key: {YOUR_API_KEY}' \
--data  '{
    "select":["*"],
    "sort":[],
    "limit":5,
    "skip":0
}
'

Example with mock values instead of the placeholders:

curl --X POST 'https://42d54rt5-d389-845a-6lkq-34z563gtu872.api.morphdb.io/v0/record/dw5g1h89-2637-253k-452b-7803j4x7e3vi/employee_csv_demo/query' \
--header 'Content-Type: application/json' \
--header 'client-type: widget' \
--header 'x-api-key: ms5sCDEOVNuIw92MNA3qLKih4xzY25D9PQY6D7Az2' \
--data  '{
    "select":["*"],
    "sort":[],
    "limit":5,
    "skip":0
}

Response

In your Terminal, you will find the following output as response::

{
    "items": [
        {
            "employee_id": "E02002",
            "full_name": "Kai Le",
            "job_title": "Manager",
            "department": "Engineering",
            "business_unit": "Manufacturing",
            "gender": "Male",
            "ethnicity": "Asian",
            "age": 47,
            "hire_date": "2022-02-05",
            "annual_salary": 92368,
            "bonus": 0,
            "country": "United States",
            "city": "Columbus",
            "exit_date": null
        },
        {
            "employee_id": "E02003",
            "full_name": "Robert Patel",
            "job_title": "Analyst",
            "department": "Sales",
            "business_unit": "Corporate",
            "gender": "Male",
            "ethnicity": "Asian",
            "age": 58,
            "hire_date": "2013-10-23",
            "annual_salary": 45703,
            "bonus": 0,
            "country": "United States",
            "city": "Chicago",
            "exit_date": null
        },
        {
            "employee_id": "E02004",
            "full_name": "Cameron Lo",
            "job_title": "Network Administrator",
            "department": "IT",
            "business_unit": "Research & Development",
            "gender": "Male",
            "ethnicity": "Asian",
            "age": 34,
            "hire_date": "2019-03-24",
            "annual_salary": 83576,
            "bonus": 0,
            "country": "China",
            "city": "Shanghai",
            "exit_date": null
        },
        {
            "employee_id": "E02005",
            "full_name": "Harper Castillo",
            "job_title": "IT Systems Architect",
            "department": "IT",
            "business_unit": "Corporate",
            "gender": "Female",
            "ethnicity": "Latino",
            "age": 39,
            "hire_date": "2018-04-07",
            "annual_salary": 98062,
            "bonus": 0,
            "country": "United States",
            "city": "Seattle",
            "exit_date": null
        },
        {
            "employee_id": "E02006",
            "full_name": "Harper Dominguez",
            "job_title": "Director",
            "department": "Engineering",
            "business_unit": "Corporate",
            "gender": "Female",
            "ethnicity": "Latino",
            "age": 42,
            "hire_date": "2005-06-18",
            "annual_salary": 175391,
            "bonus": 24,
            "country": "United States",
            "city": "Austin",
            "exit_date": null
        }
    ],
    "count": 100
}