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
- Create an account at https://smartbase.de5.net with Google and create a database in the dashboard.
- 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.
- 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 type | What it can do |
|---|---|
| read | GET requests and SQL that only reads (SELECT, SHOW, DESCRIBE) |
| write | POST, PUT, DELETE, and SQL that changes data or structure |
| collective | Creates one read key and one write key together |
- You can have up to 5 API keys per account. A key is shown only once when it is created, and only a hash is stored.
- API keys cannot create or revoke keys and cannot open the Auth & Email platform.
- Never put a write key in website or mobile app code that users can see. Keep keys on your server.
- Dashboard (browser) requests use
https://smartbase.de5.net/api/v1with your login session; programs should usehttps://smartbase.de5.net/apiv1with an API key.
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.
| Method | Path | Key | Purpose |
|---|---|---|---|
| GET | /databases | read | List your databases |
| POST | /databases | write | Create a database (name, optional description) |
| GET | /databases/:databaseId | read | Get one database |
| PUT / DELETE | /databases/:databaseId | write | Update or delete a database |
| GET | /databases/:databaseId/tables | read | List tables |
| POST | /databases/:databaseId/tables | write | Create a table (name, columns) |
| GET | /databases/:databaseId/tables/:tableId/records?page=1&limit=50 | read | List records (limit up to 100) |
| POST | /databases/:databaseId/tables/:tableId/records | write | Insert up to 100 records (records array) |
| PUT | .../records/:recordId | write | Update a record |
| DELETE | .../records/:recordId | write | Delete a record |
| POST | /query | read or write | Run SQL (database_id, sql) |
| GET | /files and /files/:name | read | List or download files |
| PUT | /files/:name | write | Upload a file up to 5 MB (raw bytes) |
| PUT | /files/:name/parts/:index?total=N&size=S | write | Upload one 5 MB part of a larger file |
| POST | /files/:name/complete | write | Finish a multi-part upload |
| POST / DELETE | /files, /files/:name | write | Upload JSON (base64) or delete a file |
| GET | /usage | read | File 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:
CREATE TABLE(withPRIMARY KEY,AUTO_INCREMENT,UNIQUE,NOT NULL,DEFAULT,CHECK),ALTER TABLE,DROP TABLE,TRUNCATE, views and indexes.INSERT(multi-row,INSERT ... SELECT,ON DUPLICATE KEY UPDATE),UPDATEandDELETEwith expressions.SELECTwithDISTINCT, allJOINtypes,WHERE,GROUP BY,HAVING,ORDER BY,LIMIT/OFFSET, subqueries,WITH(including recursive),UNION/INTERSECT/EXCEPT,CASE,CAST,LIKE,BETWEEN,INand more than 60 functions and aggregates.BEGIN/COMMIT/ROLLBACK,SHOW TABLES,DESCRIBE, andCREATE DATABASE/SHOW DATABASES/DROP DATABASE.
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)
- 20 databases, 50 tables per database, 500 tables in total.
- 5 API keys per account.
- 2 MB request body for normal API calls.
- Files: 50 MB per file, 1 GB free storage per account (files in your own Backblaze bucket are not counted).
- API keys are limited to 20 requests per minute and 2,000 requests per day. When you reach a limit the API answers
429withRATE_LIMIT_EXCEEDEDand a retry time.
Errors
Errors look like {"success": false, "error": "CODE", "message": "Explanation"}.
| Code | Meaning |
|---|---|
UNAUTHORIZED | Missing or invalid API key or login |
KEY_PERMISSION_DENIED | The key type is not allowed for this action (for example a read key trying to write) |
RATE_LIMIT_EXCEEDED | Too many requests; wait and retry |
DATABASE_NOT_FOUND, TABLE_NOT_FOUND | The id does not exist or is not yours |
INVALID_SQL, SQL_ERROR | The SQL could not be parsed or failed (nothing was saved) |
DATABASE_LIMIT_REACHED, TABLE_LIMIT_REACHED | A free-plan limit was reached |
FILE_TOO_LARGE, STORAGE_QUOTA_EXCEEDED, INVALID_PART | File 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:
- Google app options - use the default Smartbase Google app, or your own Google client ID and secret.
- Custom sign-in domain - let Google redirect through your own domain by forwarding
/__smartbase/*to Smartbase (needs your own Google app). - User storage - keep users with the platform, in your own Smartbase database (ready-made template, or a custom table described with the
smartbase-data.jsSDK), or send each sign-in to your own server through a signed gateway. - Account control - "one account, one device": monitor to count real users without duplicates, or enforce to block a second account on the same device.
- Database copy - download an offline HTML copy of your users' data.
- Broadcasts - send test emails and mass emails with sent and opened tracking; every email includes an unsubscribe link.
Security
- Passwords (for accounts that use one) are stored only as salted hashes, and API keys only as hashes.
- Every request is checked against the account that owns the data.
- Traffic is encrypted with HTTPS. Secrets such as Google client secrets are encrypted before storage.
- Report a security problem to emalawi19@gmail.com.
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).