Compute API
The Lineserve Compute API allows you to programmatically manage virtual private servers (VPS), dedicated servers, and Kubernetes clusters.
Base URLโ
https://api.lineserve.com/v1
Authenticationโ
All API requests require authentication using an API key in the Authorization header:
Authorization: Bearer YOUR_API_KEY
VPS Managementโ
List VPS Instancesโ
Get a list of all VPS instances in your account.
Endpoint: GET /vps
Parameters:
region
(optional): Filter by regionstatus
(optional): Filter by status (running, stopped, creating, etc.)page
(optional): Page number for paginationper_page
(optional): Number of results per page (max 100)
Example Request:
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.lineserve.com/v1/vps?region=nairobi&status=running"
Example Response:
{
"vps_instances": [
{
"id": "vps_123456",
"name": "web-server-prod",
"status": "running",
"region": "nairobi",
"image": "ubuntu-22.04",
"size": "starter",
"vcpus": 1,
"memory": 1024,
"disk": 25,
"ip_address": "192.168.1.100",
"private_ip": "10.0.1.100",
"created_at": "2024-01-15T10:30:00Z",
"tags": ["production", "web"]
}
],
"meta": {
"total": 1,
"page": 1,
"per_page": 25,
"pages": 1
}
}
Create VPS Instanceโ
Create a new VPS instance.
Endpoint: POST /vps
Parameters:
name
(required): Instance nameregion
(required): Deployment regionimage
(required): Operating system imagesize
(required): Instance sizessh_keys
(optional): Array of SSH key IDsprivate_networking
(optional): Enable private networkingbackups
(optional): Enable automatic backupsmonitoring
(optional): Enable enhanced monitoringuser_data
(optional): Cloud-init scripttags
(optional): Array of tags
Example Request:
curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "my-web-server",
"region": "nairobi",
"image": "ubuntu-22.04",
"size": "starter",
"ssh_keys": ["ssh_key_123"],
"private_networking": true,
"backups": true,
"tags": ["web", "production"]
}' \
https://api.lineserve.com/v1/vps
Example Response:
{
"vps": {
"id": "vps_789012",
"name": "my-web-server",
"status": "creating",
"region": "nairobi",
"image": "ubuntu-22.04",
"size": "starter",
"vcpus": 1,
"memory": 1024,
"disk": 25,
"ip_address": null,
"private_ip": null,
"created_at": "2024-01-15T11:00:00Z",
"tags": ["web", "production"]
}
}
Get VPS Instanceโ
Retrieve details of a specific VPS instance.
Endpoint: GET /vps/{vps_id}
Example Request:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.lineserve.com/v1/vps/vps_123456
Update VPS Instanceโ
Update VPS instance properties.
Endpoint: PUT /vps/{vps_id}
Parameters:
name
(optional): New instance nametags
(optional): Update tags
Example Request:
curl -X PUT -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "updated-web-server",
"tags": ["web", "production", "updated"]
}' \
https://api.lineserve.com/v1/vps/vps_123456
Delete VPS Instanceโ
Delete a VPS instance permanently.
Endpoint: DELETE /vps/{vps_id}
Example Request:
curl -X DELETE -H "Authorization: Bearer YOUR_API_KEY" \
https://api.lineserve.com/v1/vps/vps_123456
VPS Actionsโ
Start VPSโ
Start a stopped VPS instance.
Endpoint: POST /vps/{vps_id}/actions
Example Request:
curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"type": "start"}' \
https://api.lineserve.com/v1/vps/vps_123456/actions
Stop VPSโ
Stop a running VPS instance.
Example Request:
curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"type": "stop"}' \
https://api.lineserve.com/v1/vps/vps_123456/actions
Restart VPSโ
Restart a VPS instance.
Example Request:
curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"type": "restart"}' \
https://api.lineserve.com/v1/vps/vps_123456/actions
Resize VPSโ
Change the size of a VPS instance.
Parameters:
size
(required): New instance size
Example Request:
curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "resize",
"size": "professional"
}' \
https://api.lineserve.com/v1/vps/vps_123456/actions
Create Snapshotโ
Create a snapshot of a VPS instance.
Parameters:
name
(required): Snapshot name
Example Request:
curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "snapshot",
"name": "backup-2024-01-15"
}' \
https://api.lineserve.com/v1/vps/vps_123456/actions
Rebuild VPSโ
Rebuild a VPS instance with a new image.
Parameters:
image
(required): New operating system image
Example Request:
curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "rebuild",
"image": "ubuntu-22.04"
}' \
https://api.lineserve.com/v1/vps/vps_123456/actions
VPS Metricsโ
Get VPS Metricsโ
Retrieve performance metrics for a VPS instance.
Endpoint: GET /vps/{vps_id}/metrics
Parameters:
start
(optional): Start time (ISO 8601 format)end
(optional): End time (ISO 8601 format)interval
(optional): Data interval (1m, 5m, 1h, 1d)
Example Request:
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.lineserve.com/v1/vps/vps_123456/metrics?interval=5m"
Example Response:
{
"metrics": {
"cpu": [
{"timestamp": "2024-01-15T12:00:00Z", "value": 25.5},
{"timestamp": "2024-01-15T12:05:00Z", "value": 30.2}
],
"memory": [
{"timestamp": "2024-01-15T12:00:00Z", "value": 512},
{"timestamp": "2024-01-15T12:05:00Z", "value": 520}
],
"disk": [
{"timestamp": "2024-01-15T12:00:00Z", "value": 15.2},
{"timestamp": "2024-01-15T12:05:00Z", "value": 15.3}
],
"network_in": [
{"timestamp": "2024-01-15T12:00:00Z", "value": 1024},
{"timestamp": "2024-01-15T12:05:00Z", "value": 2048}
],
"network_out": [
{"timestamp": "2024-01-15T12:00:00Z", "value": 512},
{"timestamp": "2024-01-15T12:05:00Z", "value": 1024}
]
}
}
Imagesโ
List Available Imagesโ
Get a list of available operating system images.
Endpoint: GET /images
Parameters:
type
(optional): Filter by type (linux, windows)distribution
(optional): Filter by distribution
Example Request:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.lineserve.com/v1/images
Example Response:
{
"images": [
{
"id": "ubuntu-22.04",
"name": "Ubuntu 22.04 LTS",
"distribution": "ubuntu",
"version": "22.04",
"type": "linux",
"description": "Ubuntu 22.04 LTS (Jammy Jellyfish)",
"min_disk_size": 20,
"created_at": "2024-01-01T00:00:00Z"
},
{
"id": "windows-server-2022",
"name": "Windows Server 2022",
"distribution": "windows",
"version": "2022",
"type": "windows",
"description": "Windows Server 2022 Standard",
"min_disk_size": 40,
"created_at": "2024-01-01T00:00:00Z"
}
]
}
Sizesโ
List Available Sizesโ
Get a list of available VPS sizes.
Endpoint: GET /sizes
Example Request:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.lineserve.com/v1/sizes
Example Response:
{
"sizes": [
{
"slug": "starter",
"name": "Starter",
"vcpus": 1,
"memory": 1024,
"disk": 25,
"transfer": 1000,
"price_monthly": 5.00,
"price_hourly": 0.007,
"available": true
},
{
"slug": "professional",
"name": "Professional",
"vcpus": 2,
"memory": 4096,
"disk": 80,
"transfer": 3000,
"price_monthly": 20.00,
"price_hourly": 0.030,
"available": true
}
]
}
Regionsโ
List Available Regionsโ
Get a list of available deployment regions.
Endpoint: GET /regions
Example Request:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.lineserve.com/v1/regions
Example Response:
{
"regions": [
{
"slug": "nairobi",
"name": "Nairobi",
"country": "Kenya",
"continent": "Africa",
"available": true,
"features": ["vps", "databases", "storage", "kubernetes"]
},
{
"slug": "cape-town",
"name": "Cape Town",
"country": "South Africa",
"continent": "Africa",
"available": true,
"features": ["vps", "databases", "storage"]
}
]
}
SSH Keysโ
List SSH Keysโ
Get a list of SSH keys in your account.
Endpoint: GET /ssh-keys
Example Request:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.lineserve.com/v1/ssh-keys
Add SSH Keyโ
Add a new SSH key to your account.
Endpoint: POST /ssh-keys
Parameters:
name
(required): Key namepublic_key
(required): SSH public key content
Example Request:
curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "My Laptop Key",
"public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ..."
}' \
https://api.lineserve.com/v1/ssh-keys
Snapshotsโ
List Snapshotsโ
Get a list of VPS snapshots.
Endpoint: GET /snapshots
Example Request:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.lineserve.com/v1/snapshots
Delete Snapshotโ
Delete a VPS snapshot.
Endpoint: DELETE /snapshots/{snapshot_id}
Example Request:
curl -X DELETE -H "Authorization: Bearer YOUR_API_KEY" \
https://api.lineserve.com/v1/snapshots/snapshot_123456
Error Handlingโ
HTTP Status Codesโ
200
- Success201
- Created204
- No Content400
- Bad Request401
- Unauthorized403
- Forbidden404
- Not Found422
- Unprocessable Entity429
- Rate Limited500
- Internal Server Error
Error Response Formatโ
{
"error": {
"code": "validation_error",
"message": "The request could not be processed",
"details": [
{
"field": "name",
"message": "Name is required"
}
]
}
}
Rate Limitingโ
- Rate Limit: 1000 requests per hour per API key
- Headers: Rate limit information in response headers
- Burst Limit: 100 requests per minute
Rate Limit Headers:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1642248000
Paginationโ
Large result sets are paginated:
Parameters:
page
: Page number (default: 1)per_page
: Results per page (default: 25, max: 100)
Response Meta:
{
"meta": {
"total": 150,
"page": 1,
"per_page": 25,
"pages": 6
}
}
Webhooksโ
Configure webhooks to receive real-time notifications:
Events:
vps.created
vps.started
vps.stopped
vps.deleted
vps.resized
snapshot.created
snapshot.deleted
Webhook Payload:
{
"event": "vps.created",
"timestamp": "2024-01-15T12:00:00Z",
"data": {
"vps": {
"id": "vps_123456",
"name": "web-server",
"status": "running"
}
}
}
SDKs and Librariesโ
Official SDKs available for:
- Node.js:
npm install @lineserve/node
- Python:
pip install lineserve
- PHP:
composer require lineserve/php
- Go:
go get github.com/lineserve/go