1.5 KiB
1.5 KiB
API Examples
Soul is consist of 3 main namespaces: /tables, /rows and /. In this document we'll try to go over all of them so you can get familiar with how Soul works.
Setup Environment
To follow the below examples we need to download a sample database and also install Soul CLI.
Download Sample Database
wget https://raw.githubusercontent.com/lerocha/chinook-database/master/ChinookDatabase/DataSources/Chinook_Sqlite.sqlite # Download sample sqlite database
Using Soul CLI
npm install -g soul-cli
soul -d ./Chinook_Sqlite.sqlite -p 8000
Or Using Local Development
git clone https://github.com/thevahidal/soul # Clone project
npm install # Install dependencies
npm link # might need `sudo`
soul -d ./Chinook_Sqlite.sqlite -p 8000
Namespaces
- /api/tables Examples for Tables endpoints
- /api/rows Examples for Rows endpoints
- /api/ Examples for Root endpoints
Handling Errors
If an error occurs while processing a request, it will be indicated via the presence of an error key and a message in the JSON response. For example:
curl --request POST \
--url http://localhost:8000/api/tables \
--header 'Content-Type: application/json' \
--data '{
"name": "Artist", # note that we already have an `artists` table
"schema": [
# ...
]
}'
{
"message": "table artists already exists",
"error": {
"code": "SQLITE_ERROR"
}
}