This chapter provides step-by-step instructions on how to perform basic CRUD operations (Create, Read, Update, and Delete) using Morph’s API. Through this tutorial, you can easily start working with Morph’s database.

In this example, the API is invoked using the cURL command, so you can try it out by pasting the command into your terminal environment or an API client tool such as Postman.

API calls

[**Your_DatabaseID**], [Your_Table_Slug], [Your_API_Key] should be substituted.

Create:

To create new data, use the POST method.

curl --location --request POST 'https://beta-api.morphdb.io/v0/rest/[Your_DatabaseID]/[Your_Table_Slug]' \
--header 'x-api-key: [Your_API_Key]' \
--header 'Content-Type: application/json' \
--data-raw '{
    "column1": "value1",
    "column2": "value2"
}'

Read:

To read data from a table, use the GET method.

curl --location 'https://beta-api.morphdb.io/v0/rest/[Your_DatabaseID]/[Your_Table_Slug]' \
--header 'x-api-key: [Your_API_Key]'

Update:

To update existing data, use the PUT method.

curl --location --request PUT 'https://beta-api.morphdb.io/v0/rest/[Your_DatabaseID]/[Your_Table_Slug]' \
--header 'x-api-key: [Your_API_Key]' \
--header 'Content-Type: application/json' \
--data-raw '{
    "column1": "new_value1"
}'

Delete:

To delete data, use the DELETE method.

curl --location --request DELETE 'https://beta-api.morphdb.io/v0/rest/[Your_DatabaseID]/[Your_Table_Slug]' \
--header 'x-api-key: [Your_API_Key]' \
--header 'Content-Type: application/json' \
--data-raw '{
    "column1": "value_to_delete"
}'

In addition to these, PostgREST allows various query patterns to be realized according to the users’s application. For more information, please see the following reference documents.

Reference: