Get started with Eden-MDBS in 5 minutes. This guide assumes you have a running Eden-MDBS instance.
Every operation in Eden-MDBS is scoped to an organization. Organizations require a creation token (set via EDEN_NEW_ORG_TOKEN environment variable on the server).
curl http://{host}:8000/api/v1/new \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {EDEN_NEW_ORG_TOKEN}" \
-d '{
"id": "quickstart",
"super_admins": [
{
"username": "admin",
"password": "secure_password_123"
}
]
}'Response:
{
"id": "quickstart",
"uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}You now have:
quickstartadmin with password secure_password_123Eden-MDBS uses JWT tokens for authenticated requests. Login with basic auth to get a token:
curl http://{host}:8000/api/v1/auth/login \
-u admin:secure_password_123 \
-X POSTResponse:
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}Save this token - you'll use it for subsequent requests. For convenience in this guide, export it:
export TOKEN="<paste your token here>"Connect a PostgreSQL database:
curl http://{host}:8000/api/v1/endpoints \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"id": "mydb",
"kind": "Postgres",
"config": {
"write_conn": {
"url": "postgresql://user:password@db-host:5432/database"
}
}
}'Note: Replace the connection URL with your actual PostgreSQL credentials and host.
Response:
{
"id": "mydb",
"uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}You've connected a PostgreSQL endpoint named mydb.
Write to the endpoint (create a table):
curl http://{host}:8000/api/v1/endpoints/mydb/write \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"query": "CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY, name TEXT, email TEXT)"
}'Insert data:
curl http://{host}:8000/api/v1/endpoints/mydb/write \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"query": "INSERT INTO users (name, email) VALUES ('\''Alice'\'', '\''alice@example.com'\''), ('\''Bob'\'', '\''bob@example.com'\'')"
}'Read data:
curl http://{host}:8000/api/v1/endpoints/mydb/read \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"query": "SELECT * FROM users"
}'Response:
{
"rows": [
{ "id": 1, "name": "Alice", "email": "alice@example.com" },
{ "id": 2, "name": "Bob", "email": "bob@example.com" }
]
}Add Redis as a caching endpoint:
curl http://{host}:8000/api/v1/endpoints \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"id": "cache",
"kind": "Redis",
"config": {
"write_conn": {
"url": "redis://redis-host:6379"
}
}
}'Write a key:
curl http://{host}:8000/api/v1/endpoints/cache/write \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"command": "SET",
"args": ["user:1", "{\"name\": \"Alice\", \"email\": \"alice@example.com\"}"]
}'Read the key:
curl http://{host}:8000/api/v1/endpoints/cache/read \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"command": "GET",
"args": ["user:1"]
}'Eden-MDBS includes auto-generated API documentation:
http://{host}:8000/swagger-ui/http://{host}:8000/api-docs/openapi.jsonCongratulations! You've:
Connect additional database types: