Scripts
List scripts
curl --request GET \
--url http://localhost:3000/api/v1/scripts/-1 \
--header 'Authorization: Basic OmJsYWNrU7dhbjEyMw==' \
{
"scripts": [
{
"id": 2,
"lang": "lua",
"name": "new_script",
"source": "\n-- This is a sample script\n-- Fill in the onRecord function to transform the incoming record\nlocal json = require \"json\"\n\nfunction onRecord(r)\n return json.encode(r.row)\nend"
},
{
"id": 3,
"lang": "lua",
"name": "good_script",
"source": "\n-- This is a sample script\n-- Fill in the onRecord function to transform the incoming record\nlocal json = require \"json\"\n\nfunction onRecord(r)\n return json.encode(r.row)\nend"
},
{
"id": 4,
"lang": "lua",
"name": "bad_script",
"source": "\n-- This is a sample script\n-- Fill in the onRecord function to transform the incoming record\nlocal json = require \"json\"\n\nfunction onRecord(r)\n return json.encode(r.row)\nend"
}
]
}
GET /api/v1/scripts/{id}
This endpoint is used to get a script by its ID. If the ID is -1, it returns all scripts.
Scripts are disabled by default in PeerDB Cloud. It is enabled in PeerDB OSS and PeerDB Enterprise.
Request Fields
Describe a script by its ID. If the ID is -1, it returns all scripts.
Response Fields
An array of scripts.
curl --request GET \
--url http://localhost:3000/api/v1/scripts/-1 \
--header 'Authorization: Basic OmJsYWNrU7dhbjEyMw==' \
{
"scripts": [
{
"id": 2,
"lang": "lua",
"name": "new_script",
"source": "\n-- This is a sample script\n-- Fill in the onRecord function to transform the incoming record\nlocal json = require \"json\"\n\nfunction onRecord(r)\n return json.encode(r.row)\nend"
},
{
"id": 3,
"lang": "lua",
"name": "good_script",
"source": "\n-- This is a sample script\n-- Fill in the onRecord function to transform the incoming record\nlocal json = require \"json\"\n\nfunction onRecord(r)\n return json.encode(r.row)\nend"
},
{
"id": 4,
"lang": "lua",
"name": "bad_script",
"source": "\n-- This is a sample script\n-- Fill in the onRecord function to transform the incoming record\nlocal json = require \"json\"\n\nfunction onRecord(r)\n return json.encode(r.row)\nend"
}
]
}
curl --request GET \
--url http://localhost:3000/api/v1/scripts/-1 \
--header 'Authorization: Basic OmJsYWNrU7dhbjEyMw==' \
{
"scripts": [
{
"id": 2,
"lang": "lua",
"name": "new_script",
"source": "\n-- This is a sample script\n-- Fill in the onRecord function to transform the incoming record\nlocal json = require \"json\"\n\nfunction onRecord(r)\n return json.encode(r.row)\nend"
},
{
"id": 3,
"lang": "lua",
"name": "good_script",
"source": "\n-- This is a sample script\n-- Fill in the onRecord function to transform the incoming record\nlocal json = require \"json\"\n\nfunction onRecord(r)\n return json.encode(r.row)\nend"
},
{
"id": 4,
"lang": "lua",
"name": "bad_script",
"source": "\n-- This is a sample script\n-- Fill in the onRecord function to transform the incoming record\nlocal json = require \"json\"\n\nfunction onRecord(r)\n return json.encode(r.row)\nend"
}
]
}