Internal API

SlashDB possess an internal API (JSON only), useful for automated configuration management. We can do basic CRUD database, user and query configurations using API calls. This functionality is only available for logged in users (using a cookie) or request performed with an valid user API key.

All of these operations can be done using your prefered request library or simply curl. We also provide angular-slashdb SDK, that enables doing these API operations from an angular frontend app.

Database Configuration API

List

curl example:

# get list
curl https://demo.slashdb.com/dbdef.json -H 'apikey: validuserapikey' -i

Get

# get single query
curl https://demo.slashdb.com/dbdef/MyNewDB.json -H 'apikey: validuserapikey' -i

Create

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

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

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: *

angular-slashdb API references:

User Configuration API

List

curl example:

# get list
curl https://demo.slashdb.com/userdef.json -i \
-H 'apikey: validuserapikey'

Get

# get single query
curl https://demo.slashdb.com/userdef/MyNewUser.json -i \
-H 'apikey: validuserapikey'

Create

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

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

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: *

angular-slashdb API references:

Query Configuration API

List

curl example:

# get list
curl https://demo.slashdb.com/querydef.json -i \
-H 'apikey: validuserapikey'

Get

# get single query
curl https://demo.slashdb.com/querydef/MyNewQuery.json -i \
-H 'apikey: validuserapikey'

Create

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

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

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: *

angular-slashdb API references:

results matching ""

    No results matching ""