Smartbase documentation

Smartbase is a cloud database and developer platform made by Miyoni. This guide covers the dashboard, the REST API, SQL, file storage and the Auth & Email platform. Base address of the API: https://smartbase.de5.net/apiv1.

Quick start

  1. Create an account at https://smartbase.de5.net with Google and create a database in the dashboard.
  2. Open API Center and create an API key. A read key can only read, a write key can change data, and a collective key creates one of each.
  3. Make your first request:
curl -X POST https://smartbase.de5.net/apiv1/query \
  -H "Authorization: Bearer YOUR_READ_KEY" \
  -H "Content-Type: application/json" \
  -d '{"database_id":"YOUR_DATABASE_ID","sql":"SELECT * FROM customers LIMIT 10"}'

Authentication and API keys

Send your key in the Authorization: Bearer YOUR_API_KEY header, or in an X-API-Key header.

Key typeWhat it can do
readGET requests and SQL that only reads (SELECT, SHOW, DESCRIBE)
writePOST, PUT, DELETE, and SQL that changes data or structure
collectiveCreates one read key and one write key together

Endpoints

All paths below are relative to https://smartbase.de5.net/apiv1. Every response is JSON with "success": true or "success": false and an error code.

MethodPathKeyPurpose
GET/databasesreadList your databases
POST/databaseswriteCreate a database (name, optional description)
GET/databases/:databaseIdreadGet one database
PUT / DELETE/databases/:databaseIdwriteUpdate or delete a database
GET/databases/:databaseId/tablesreadList tables
POST/databases/:databaseId/tableswriteCreate a table (name, columns)
GET/databases/:databaseId/tables/:tableId/records?page=1&limit=50readList records (limit up to 100)
POST/databases/:databaseId/tables/:tableId/recordswriteInsert up to 100 records (records array)
PUT.../records/:recordIdwriteUpdate a record
DELETE.../records/:recordIdwriteDelete a record
POST/queryread or writeRun SQL (database_id, sql)
GET/files and /files/:namereadList or download files
PUT/files/:namewriteUpload a file up to 5 MB (raw bytes)
PUT/files/:name/parts/:index?total=N&size=SwriteUpload one 5 MB part of a larger file
POST/files/:name/completewriteFinish a multi-part upload
POST / DELETE/files, /files/:namewriteUpload JSON (base64) or delete a file
GET/usagereadFile storage used and remaining

Column types are INTEGER, FLOAT, TEXT, BOOLEAN, DATE, DATETIME and JSON. Example table and record:

curl -X POST https://smartbase.de5.net/apiv1/databases/DB_ID/tables -H "Authorization: Bearer WRITE_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"customers","columns":[{"name":"name","type":"TEXT","nullable":false},{"name":"age","type":"INTEGER","nullable":true}]}'

curl -X POST https://smartbase.de5.net/apiv1/databases/DB_ID/tables/TABLE_ID/records -H "Authorization: Bearer WRITE_KEY" \
  -H "Content-Type: application/json" -d '{"records":[{"name":"Ann","age":30}]}'

SQL

Send SQL to POST /query with the database_id and the sql text. You can send several statements separated by ;. If one statement fails, none of the statements in that request are saved. A script that only reads needs a read key; anything else needs a write key.

Supported SQL:

Not available yet: window functions (OVER), triggers and stored procedures.

{"success": true, "columns": ["customer","spent"], "rows": [{"customer":"Ann","spent":120.5}], "count": 1, "execution_time": 14}

Files

Upload with a write key by sending the file bytes as the body, then download or list with a read key:

curl -X PUT https://smartbase.de5.net/apiv1/files/photo.jpg -H "Authorization: Bearer WRITE_KEY" \
  -H "Content-Type: image/jpeg" --data-binary @photo.jpg
curl https://smartbase.de5.net/apiv1/files -H "Authorization: Bearer READ_KEY"
curl -o photo.jpg https://smartbase.de5.net/apiv1/files/photo.jpg -H "Authorization: Bearer READ_KEY"

Files over 5 MB (up to 50 MB) are sent in parts of exactly 5 MB (the last part is smaller): PUT /files/NAME/parts/INDEX?total=N&size=SIZE for each part, then POST /files/NAME/complete with total, size and content_type. The dashboard does this for you and shows a progress bar. Files can also be uploaded as JSON (POST /files with name, base64 data and content_type, up to 5 MB).

You can also send your files to your own Backblaze B2 bucket (External Storage in the dashboard). Then uploads go straight to your bucket and do not use the free storage.

Limits (free plan)

Errors

Errors look like {"success": false, "error": "CODE", "message": "Explanation"}.

CodeMeaning
UNAUTHORIZEDMissing or invalid API key or login
KEY_PERMISSION_DENIEDThe key type is not allowed for this action (for example a read key trying to write)
RATE_LIMIT_EXCEEDEDToo many requests; wait and retry
DATABASE_NOT_FOUND, TABLE_NOT_FOUNDThe id does not exist or is not yours
INVALID_SQL, SQL_ERRORThe SQL could not be parsed or failed (nothing was saved)
DATABASE_LIMIT_REACHED, TABLE_LIMIT_REACHEDA free-plan limit was reached
FILE_TOO_LARGE, STORAGE_QUOTA_EXCEEDED, INVALID_PARTFile limits were reached, or a part had the wrong size

Auth and Email platform

The Auth & Email platform lets visitors of your website sign in with Google, and gives you tools to manage those users. Open it from the Auth & Email option in the Smartbase menu; you are signed in automatically. It currently runs at https://email.emalawi19.workers.dev.

Add the sign-in button to your site:

<div id="google-login"></div>
<script src="https://email.emalawi19.workers.dev/smartbase.js"></script>
<script>
  Smartbase.init({ projectId: "YOUR_PROJECT_ID" });
  Smartbase.googleButton("#google-login");
  var result = Smartbase.getRedirectResult();
  if (result && result.code) {
    // send result.code to YOUR server, then exchange it with your secret key
  }
</script>

On your server, exchange the one-time code for the verified profile with POST https://email.emalawi19.workers.dev/api/v1/google/exchange, sending your project key in the X-Smartbase-Key header.

Features:

Security

Frequently asked questions

Is Smartbase free?

Yes. The free plan includes the limits listed above.

Can I use Smartbase from my own website or app?

Yes. Create an API key in the API Center and call https://smartbase.de5.net/apiv1 from your server.

Can a read key delete data?

No. A read key can only read. Changing data needs a write key.

Where is my data stored?

Smartbase runs on Cloudflare, and your databases and files are stored as private files in cloud storage operated by Miyoni. See the Privacy Policy for details.

Support

Email emalawi19@gmail.com. Please include your account email and, if relevant, the error code you received (never send API keys or passwords).