Internal API
SlashDB possess an internal API that can be used for automated configuration management. Using different endpoints, you can create, modify, or delete:
This functionality is only available for authenticated users.
Info
All of these operations can be done using your preferred HTTP request library or simply curl
.
You can also use the SlashDB Javascript SDK or the SlashDB React SDK to send requests to these endpoints.
Note that the internal API is only available in JSON format.
Database Configuration API
This API allows you to update the SlashDB database configuration. It is located at /dbdef.json
.
List
Retrieve the list of database configurations.
curl example:
# get list
curl https://demo.slashdb.com/dbdef.json -H 'apikey: validuserapikey' -i
Get
Retrieve a database configuration.
# get single query
curl https://demo.slashdb.com/dbdef/MyNewDB.json -H 'apikey: validuserapikey' -i
Create
Create a database configuration.
curl example:
curl https://demo.slashdb.com/dbdef.json -i \
-H 'Content-Type: application/json' \
-H 'apikey: validuserapikey' -XPOST -d \
'{
"db_id": "MyNewDB",
"db_encoding": "utf-8",
"owners": [
"admin"
],
"creator": "admin",
"read": [],
"editable": true,
"db_type": "sqlite",
"executable": true,
"autoload_user": {
"dbuser": "",
"dbpass": ""
},
"autoload": true,
"viewable": true,
"write": [],
"connection": "/my/path/MyNewDB.sqlite",
"foreign_keys": {},
"execute": [],
"db_schema": null,
"autoconnect": true,
"alternate_key": {},
"excluded_columns": {},
"desc": "New SQLite database"
}'
# returns
HTTP/1.1 201 Created
Server: nginx/1.4.6 (Ubuntu)
Date: Fri, 02 Jun 2017 12:14:15 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 116
Connection: keep-alive
Location: https://demo.slashdb.com/dbdef/MyNewDB.json
Access-Control-Allow-Origin: *
https://demo.slashdb.com/dbdef/MyNewDB.json
Update
Update a database configuration.
curl example:
curl https://demo.slashdb.com/dbdef/MyNewDB.json -i \
-H 'Content-Type: application/json' \
-H 'apikey: validuserapikey' -XPUT -d \
'{"autoload": false}'
# returns
HTTP/1.1 204 No Content
Server: nginx/1.4.6 (Ubuntu)
Date: Fri, 02 Jun 2017 13:38:31 GMT
Connection: keep-alive
Location: https://demo.slashdb.com/dbdef/MyNewDB.json
Access-Control-Allow-Origin: *
Delete
Delete a database configuration.
curl example:
curl https://demo.slashdb.com/dbdef/MyNewDB.json -i \
-H 'apikey: validuserapikey' -XDELETE
# returns
HTTP/1.1 204 No Content
Server: nginx/1.4.6 (Ubuntu)
Date: Fri, 02 Jun 2017 13:42:08 GMT
Connection: keep-alive
Access-Control-Allow-Origin: *
User Configuration API
This API allows you to update the SlashDB user configuration. It is located at /userdef.json
.
List
Retrieve the list of user configurations.
curl example:
# get list
curl https://demo.slashdb.com/userdef.json -i \
-H 'apikey: validuserapikey'
Get
Retrieve a user configuration.
# get single query
curl https://demo.slashdb.com/userdef/MyNewUser.json -i \
-H 'apikey: validuserapikey'
Create
Create a new user configuration.
curl example:
curl https://demo.slashdb.com/userdef.json -i \
-H 'Content-Type: application/json' \
-H 'apikey: validuserapikey' -XPOST -d \
'{
"user_id": "MyNewUser",
"userdef": [],
"api_key": "new-user-api-key",
"name": "",
"creator": "admin",
"edit": [],
"dbdef": [],
"querydef": [],
"databases": {
"Chinook": {
"dbuser": "",
"dbpass": ""
}
},
"password": "newpasswd",
"email": "",
"view": []
}'
# returns
HTTP/1.1 201 Created
Server: nginx/1.4.6 (Ubuntu)
Date: Fri, 02 Jun 2017 14:45:04 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 116
Connection: keep-alive
Location: https://demo.slashdb.com/userdef/MyNewUser.json
Access-Control-Allow-Origin: *
https://demo.slashdb.com/userdef/MyNewUser.json
Update
Update a user configuration.
curl example:
curl https://demo.slashdb.com/userdef/MyNewUser.json -i \
-H 'Content-Type: application/json' \
-H 'apikey: validuserapikey' -XPUT -d \
'{"name": "John"}'
# returns
HTTP/1.1 204 No Content
Server: nginx/1.4.6 (Ubuntu)
Date: Fri, 02 Jun 2017 14:43:28 GMT
Connection: keep-alive
Location: https://demo.slashdb.com/userdef/MyNewUser.json
Access-Control-Allow-Origin: *
Delete
Delete a user configuration.
curl example:
curl https://demo.slashdb.com/userdef/MyNewUser.json -i \
-H 'Content-Type: application/json' \
-H 'apikey: validuserapikey' -XDELETE
# returns
HTTP/1.1 204 No Content
Server: nginx/1.4.6 (Ubuntu)
Date: Fri, 02 Jun 2017 14:44:03 GMT
Connection: keep-alive
Access-Control-Allow-Origin: *
Query Configuration API
This API allows you to update the SlashDB query configuration. It is located at /querydef.json
.
List
Retrieve the list of query configurations.
curl example:
# get list
curl https://demo.slashdb.com/querydef.json -i \
-H 'apikey: validuserapikey'
Get
Retrieve a query configuration.
# get single query
curl https://demo.slashdb.com/querydef/MyNewQuery.json -i \
-H 'apikey: validuserapikey'
Create
Create a query configuration.
curl example:
curl https://demo.slashdb.com/querydef.json -i \
-H 'Content-Type: application/json' \
-H 'apikey: validuserapikey' -XPOST -d \
'{
"query_id": "MyNewQuery",
"creator": "admin",
"read": [
"admin"
],
"database": "Chinook",
"execute": [
"admin",
"public"
],
"write": [
"admin"
],
"http_methods": {
"GET": true
},
"sqlstr": "select * from Customer",
"desc": "New Query Def"
}'
# returns
HTTP/1.1 201 Created
Server: nginx/1.4.6 (Ubuntu)
Date: Fri, 02 Jun 2017 12:14:15 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 116
Connection: keep-alive
Location: https://demo.slashdb.com/querydef/MyNewQuery.json
Access-Control-Allow-Origin: *
https://demo.slashdb.com/querydef/MyNewQuery.json
Update
Update a query configuration.
curl example:
curl https://demo.slashdb.com/querydef/MyNewQuery.json -i \
-H 'Content-Type: application/json' \
-H 'apikey: validuserapikey' -XPUT -d \
''{"http_methods": {"GET": true, "POST": true}}''
# returns
HTTP/1.1 204 No Content
Server: nginx/1.4.6 (Ubuntu)
Date: Fri, 02 Jun 2017 13:38:31 GMT
Connection: keep-alive
Location: https://demo.slashdb.com/querydef/MyNewQuery.json
Access-Control-Allow-Origin: *
Delete
Delete a query configuration.
curl example:
curl https://demo.slashdb.com/querydef/MyNewQuery.json -i -XDELETE \
-H 'apikey: validuserapikey'
# returns
HTTP/1.1 204 No Content
Server: nginx/1.4.6 (Ubuntu)
Date: Fri, 02 Jun 2017 13:42:08 GMT
Connection: keep-alive
Access-Control-Allow-Origin: *