Skip to main content

Database API Overview

Create, manage, and scale PostgreSQL and MariaDB databases programmatically with WAYSCloud Database API.

What is Database API?

WAYSCloud Database API (DBaaS) allows you to provision and manage relational databases without manual setup. Perfect for:

  • Application databases - Backend storage for web/mobile apps
  • Development environments - Quick database provisioning
  • Testing - Spin up/teardown test databases
  • Microservices - Each service gets its own database

Supported Database Types

PostgreSQL

Best for:

  • Web applications
  • JSON workloads (JSONB)
  • Geospatial data (PostGIS)
  • Full-text search
  • ACID compliance

Versions: 14, 15, 16

MariaDB

Best for:

  • WordPress and PHP applications
  • MySQL compatibility
  • High-performance queries
  • Read-heavy workloads

Versions: 10.11, 11.0

Key Features

✅ Automated Provisioning

Create databases in seconds via API:

curl -X POST "https://api.wayscloud.services/v1/databases" \
-H "Authorization: Bearer wayscloud_database_abc123_YourSecretKey" \
-H "Content-Type: application/json" \
-d '{"db_type": "postgresql", "db_name": "my_app_db"}'

✅ Point-in-Time Snapshots

Create backups before deployments:

curl -X POST "https://api.wayscloud.services/v1/databases/postgresql/my_app_db/snapshots" \
-H "Authorization: Bearer $WAYSCLOUD_API_KEY" \
-d '{"description": "Before v2.0 deployment"}'

✅ Automated Backups

Configure daily/hourly backups with retention policies:

{
"enabled": true,
"schedule": "daily",
"retention_days": 30,
"time": "02:00"
}

✅ Firewall Protection

Whitelist specific IP addresses for security:

curl -X POST "https://api.wayscloud.services/v1/firewall/allow" \
-H "Authorization: Bearer $WAYSCLOUD_API_KEY" \
-d '{
"db_type": "postgresql",
"db_name": "my_app_db",
"ip_address": "203.0.113.42",
"description": "Office IP"
}'

✅ Monitoring & Metrics

  • Real-time connection count
  • Database size tracking
  • Query performance stats
  • Resource usage monitoring

Quick Start

1. Create Database

import requests
import os

API_KEY = os.getenv('WAYSCLOUD_API_KEY')

response = requests.post(
'https://api.wayscloud.services/v1/databases',
headers={'Authorization': f'Bearer {API_KEY}', 'Content-Type': 'application/json'},
json={'db_type': 'postgresql', 'db_name': 'my_app_db'}
)

db_info = response.json()
print(f"Database created: {db_info['database']['db_name']}")

2. Get Credentials

creds_response = requests.get(
'https://api.wayscloud.services/v1/databases/postgresql/my_app_db/credentials',
headers={'Authorization': f'Bearer {API_KEY}'}
)

creds = creds_response.json()
print(f"Connection string: {creds['connection_string']}")

3. Connect

import psycopg2

conn = psycopg2.connect(creds['connection_string'])
cur = conn.cursor()
cur.execute('SELECT version();')
print(cur.fetchone())

API Endpoints

EndpointMethodDescription
/v1/databasesPOSTCreate database
/v1/databases/{type}GETList databases
/v1/databasesDELETEDelete database
/v1/databases/{type}/{name}/credentialsGETGet connection details
/v1/databases/{type}/{name}/infoGETGet size and stats
/v1/databases/{type}/{name}/snapshotsPOSTCreate snapshot
/v1/databases/{type}/{name}/snapshotsGETList snapshots
/v1/databases/{type}/{name}/restorePOSTRestore snapshot
/v1/databases/{type}/{name}/snapshots/{id}DELETEDelete snapshot
/v1/databases/{type}/{name}/backup-policyGET/PUTManage backups
/v1/firewall/allowPOSTAdd firewall rule
/v1/firewall/removeDELETERemove firewall rule
/v1/firewall/listGETList firewall rules

Rate Limits

  • 500 requests/minute per API key
  • 10 concurrent connections per database

Pricing

Databases are billed per hour based on:

  • Database type (PostgreSQL/MariaDB)
  • Storage used (GB)
  • Snapshot storage (GB)

Contact sales@wayscloud.no for pricing details.

Security

✅ Network Isolation

  • Databases run in private network (172.29.1.0/24)
  • Not directly accessible from internet
  • Firewall-based IP whitelisting required

✅ Encrypted Connections

  • TLS/SSL supported
  • Encrypted at rest
  • Encrypted backups

✅ Access Control

  • Unique credentials per database
  • API key authentication
  • Role-based access (coming soon)

Use Cases

Web Application Backend

# Create database for new customer
customer_db = create_database(f'customer_{customer_id}_db')

# Store connection string in secrets manager
store_secret(f'customer_{customer_id}_connection', customer_db['connection_string'])

# Auto-scale with customer growth
if customer.tier == 'enterprise':
enable_backups(customer_db, schedule='hourly')

CI/CD Pipeline

# .gitlab-ci.yml
test:
script:
# Create test database
- DB_NAME="test_${CI_PIPELINE_ID}"
- create_database $DB_NAME

# Run migrations
- python manage.py migrate

# Run tests
- pytest

after_script:
# Clean up test database
- delete_database $DB_NAME

Multi-Tenant SaaS

# Provision database per tenant
def onboard_customer(customer_id):
db = create_database(f'tenant_{customer_id}')
run_migrations(db)
configure_firewall(db, customer.office_ip)
enable_daily_backups(db)
return db['connection_string']

Limitations

ResourceLimit
Max databases per account100
Max database name length63 characters
Max connections per database100
Max database size1TB
Max snapshot retention365 days
Firewall rules per database50

Next Steps

Support