← d3dev

DigitalOcean API — Capabilities, Usage, and Building Guide

At a Glance

DigitalOcean exposes a REST API v2 for managing Droplets, App Platform, databases, Spaces, Kubernetes, domains, load balancers, firewalls, and more. Authentication uses personal access tokens (Bearer). The platform is built for simplicity and predictable pricing — ideal for solo developers and small teams who want AWS-like capabilities without the complexity. Spaces is S3-compatible; doctl is the official CLI; Node.js developers use the AWS SDK with Spaces or community libraries for the main API.

DigitalOcean API — Capabilities, Usage, and Building Guide

Metadata

FieldValue
TitleDigitalOcean API — Capabilities, Usage, and Building Guide
Author/SourceDigitalOcean (docs.digitalocean.com, digitalocean.com)
Date Downloaded2026-03-03
Tagsdigitalocean, cloud-api, vps, droplets, kubernetes, app-platform, s3

At a Glance

DigitalOcean exposes a REST API v2 for managing Droplets, App Platform, databases, Spaces, Kubernetes, domains, load balancers, firewalls, and more. Authentication uses personal access tokens (Bearer). The platform is built for simplicity and predictable pricing — ideal for solo developers and small teams who want AWS-like capabilities without the complexity. Spaces is S3-compatible; doctl is the official CLI; Node.js developers use the AWS SDK with Spaces or community libraries for the main API.

Quotes

"Keep your tokens secret. They function like passwords. Do not hard code your tokens into programs where they may accidentally be released in version control and are harder to rotate. Instead, use environment variables."

— DigitalOcean API Documentation [1]

"The Spaces API is interoperable with the AWS S3 API, meaning you can use existing S3 tools and libraries with it."

— DigitalOcean Docs [2]

"App Platform is a fully managed Platform-as-a-Service (PaaS) that deploys applications from Git repositories or container images. It automatically builds, deploys, and scales components while handling all underlying infrastructure."

— DigitalOcean App Platform Docs [3]

"DigitalOcean Droplets are often praised for their simplicity and developer-friendly interface, making them a great choice for individuals and small to medium-sized businesses. AWS EC2 offers a wider range of instance types and services, which can be more suitable for large enterprises with complex requirements. In terms of pricing, DigitalOcean is generally more affordable for comparable resources."

— DigitalOcean Pricing FAQ [4]

"doctl does not support the DigitalOcean Spaces API. However, because the Spaces API is S3-compatible, you can use S3-compatible command line tools like s3cmd to manage Spaces."

— DigitalOcean doctl Docs [5]

Sam's TLDR

DigitalOcean's API is straightforward: REST v2, bearer token auth, and well-documented endpoints for everything from spinning up Droplets to managing Kubernetes. The platform leans into predictability — flat monthly pricing, simple resource model, no hidden fees. For a solo dev or small team, it's a sweet spot between the bare-metal chaos of DIY VPS and the overwhelming breadth of AWS. Spaces is basically S3 — use the AWS SDK. App Platform deploys from Git or Docker; you can define apps in YAML and push via API or doctl. Managed databases (Postgres, MySQL, MongoDB, Valkey, etc.) start around $15/mo. The main gotchas: doctl doesn't do Spaces (use s3cmd or the AWS SDK), rate limits exist (doctl auto-retries on 429), and custom token scopes mean you can't edit scope after creation. Overall, it's a strong fit for static sites, side projects, and small production workloads — especially if you value simplicity and predictable bills.

Key Points

Full Summary

1. API Overview — REST v2, Auth, Rate Limits

Basics Personal Access Tokens Rate Limits

---

2. Droplets — Create, Manage, Resize, Snapshot

Key Endpoints
EndpointMethodDescription
/v2/dropletsGETList droplets
/v2/dropletsPOSTCreate droplet
/v2/droplets/:idGET, DELETEGet or destroy droplet
/v2/droplets/:id/actionsPOSTResize, reboot, power, snapshot
/v2/sizesGETList Droplet plans
/v2/imagesGETList base images (Ubuntu, Docker, etc.)
Example Use Cases Pricing (approximate)
PlanRAMvCPUSSD$/mo
Basic 512MB512 MiB110 GiB$4
Basic 1GB1 GiB125 GiB$6
Basic 2GB2 GiB150 GiB$12

Bandwidth: free outbound (500–11,000 GiB depending on plan); overage $0.01/GiB. Inbound free [7].

Gotchas

---

3. App Platform — Git, Static, Docker

Capabilities Key Endpoints
EndpointMethodDescription
/v2/appsGET, POSTList or create apps
/v2/apps/:idGET, PUT, DELETEGet, update, delete app
/v2/apps/:id/deploymentsGET, POSTList or trigger deployments
Example Use Cases Pricing
PlanCPUsRAM$/mo
Free static$0 (3 apps, 1 GiB transfer each)
apps-s-1vcpu-0.5gb1 shared512 MiB$5
apps-s-1vcpu-1gb1 shared1 GiB$12
apps-d-1vcpu-1gb (dedicated)1 dedicated1 GiB$34
Gotchas

---

4. Managed Databases — Postgres, MySQL, Redis, MongoDB, etc.

Engines

PostgreSQL, MySQL, MongoDB, Valkey (Redis-compatible), Kafka, OpenSearch

Key Endpoints
EndpointMethodDescription
/v2/databasesGET, POSTList or create clusters
/v2/databases/:idGET, DELETEGet or destroy cluster
/v2/databases/:id/usersGET, POSTManage users
/v2/databases/:id/dbsGET, POSTManage databases
Example Use Cases Pricing
EngineSmallest Plan$/mo
PostgreSQL/MySQL1 vCPU, 1 GiB~$15
Valkey1 vCPU, 1 GiB$15
MongoDB1 vCPU, 1 GiB~$15
OpenSearch1 vCPU, 2 GiB~$20

Storage: $0.215/GiB/mo (varies by engine)

Gotchas

---

5. Spaces — S3-Compatible Object Storage

API Example Use Cases Pricing
ItemCost
Base subscription$5/mo
Included storage250 GiB
Extra storage$0.02/GiB/mo
Included bandwidth1,024 GiB
Overage bandwidth$0.01/GiB

CDN included. Same-region Droplet → Spaces transfer free for some region pairs [11].

Gotchas

---

6. Kubernetes (DOKS)

Key Endpoints
EndpointMethodDescription
/v2/kubernetes/clustersGET, POSTList or create clusters
/v2/kubernetes/clusters/:idGET, PUT, DELETEManage cluster
/v2/kubernetes/optionsGETNode sizes, versions
Example Use Cases Pricing

---

7. Domains and DNS

Key Endpoints
EndpointMethodDescription
/v2/domainsGET, POSTList or add domains
/v2/domains/:name/recordsGET, POSTList or create DNS records
/v2/domains/:name/records/:idGET, PUT, DELETEManage record
Example Use Cases

---

8. Load Balancers and Networking

Load Balancers VPC Firewalls

---

9. Monitoring and Alerts

Monitoring Uptime

---

10. doctl and Client Libraries

doctl Client Libraries

---

11. Pricing Overview

ProductStarting PriceNotes
Droplets$4/moPer-second billing, 60s min
App Platform$0 (static)3 free static sites
App Platform (paid)$5/moPer component
Managed Databases$15/moPostgres, MySQL, Valkey
Spaces$5/mo250 GiB, 1,024 GiB transfer
Kubernetes$12/moWorker nodes only
Load Balancers$12/mo
Backups20–30% of DropletWeekly or daily
Bandwidth overage$0.01/GiBAcross products

---

DigitalOcean vs. AWS/GCP for Small–Medium Projects

AspectDigitalOceanAWS / GCP
Learning curveLowHigh
Pricing modelFlat, predictableComplex, many variables
Service breadthFocused (VMs, DB, K8s, storage)Very broad
Ideal forSolo devs, startups, side projectsEnterprises, complex workloads
API simplicityREST v2, straightforwardMultiple APIs, SDK-heavy
SupportCommunity, paid tiersEnterprise support available
Takeaway: DigitalOcean excels when you want fast setup, predictable bills, and a narrow but sufficient feature set. AWS/GCP make sense when you need specific services (e.g., Lambda, BigQuery) or global multi-region complexity [4].

---

Best Practices for Solo Developer / Small Team

  • Token security — Use env vars, never commit tokens. Rotate periodically [1].
  • Custom scopes — Grant least privilege; e.g., droplet:create only for provisioning scripts.
  • Infrastructure as code — Use app specs (YAML) for App Platform; Terraform/Pulumi for Droplets and networking.
  • Billing alerts — Set up alerts to avoid surprises.
  • VPC by default — New resources go in VPC; private traffic doesn't count against bandwidth.
  • Reconnection logic — For managed databases, implement retry/reconnect for brief failover windows [9].
  • doctl for day-to-day — Faster than API for ad-hoc tasks; script API for automation.
  • ---

    Deploy a Static Site via the API

    Option A: App Platform
  • Create app spec YAML with static_sites component, github repo, source_dir, output_dir (e.g., build).
  • POST /v2/apps with the spec.
  • Trigger deployment: POST /v2/apps/:id/deployments.
  • Option B: Spaces
  • Create Space via Control Panel or Spaces API (S3-compatible).
  • Upload built files with aws s3 sync build/ s3://bucket-name/ (or AWS SDK).
  • Enable CDN and optional custom domain.
  • Configure index/error documents for SPA if needed.
  • ---

    Set Up a VPS with Docker via the API

  • Create DropletPOST /v2/droplets with:
  • - image: docker-24-04 or docker-24-04-x64 (Docker 1-Click image)

    - size: e.g., s-1vcpu-1gb

    - region, name, ssh_keys

  • Wait for creation — Poll /v2/droplets/:id or use actions API.
  • User data (optional) — Pass cloud-init in user_data to install Docker, run docker-compose, etc.
  • Connect — SSH with key; Docker pre-installed on 1-Click image.
  • Alternatively, use a standard Ubuntu image and provide user_data with Docker install script.

    ---

    References

    1. [1]How to Create a Personal Access Token. DigitalOcean Documentation. https://docs.digitalocean.com/reference/api/create-personal-access-token/
    2. [2]API Overview. DigitalOcean Documentation. https://docs.digitalocean.com/reference/api/
    3. [3]App Platform. DigitalOcean Documentation. https://docs.digitalocean.com/products/app-platform/
    4. [4]Droplet Pricing. DigitalOcean. https://www.digitalocean.com/pricing/droplets
    5. [5]doctl Command Line Interface (CLI). DigitalOcean Documentation. https://docs.digitalocean.com/reference/doctl/
    6. [6]DigitalOcean API Reference. DigitalOcean Documentation. https://docs.digitalocean.com/reference/api/api-reference/
    7. [7]Droplet Pricing. DigitalOcean Documentation. https://docs.digitalocean.com/products/droplets/details/pricing/
    8. [8]App Platform Pricing. DigitalOcean Documentation. https://docs.digitalocean.com/products/app-platform/details/pricing/
    9. [9]Managed Databases. DigitalOcean Documentation. https://docs.digitalocean.com/products/databases/
    10. [10]Managed Database Pricing. DigitalOcean. https://www.digitalocean.com/pricing/managed-databases
    11. [11]Spaces Pricing. DigitalOcean Documentation. https://docs.digitalocean.com/products/spaces/details/pricing/
    12. [12]DigitalOcean Kubernetes. DigitalOcean Documentation. https://docs.digitalocean.com/products/kubernetes/
    13. [13]Domains and DNS. DigitalOcean Documentation. https://docs.digitalocean.com/products/networking/dns/
    14. [14]Load Balancers. DigitalOcean Documentation. https://docs.digitalocean.com/products/networking/load-balancers/
    15. [15]VPC. DigitalOcean Documentation. https://docs.digitalocean.com/products/networking/vpc/
    16. [16]Monitoring. DigitalOcean Documentation. https://docs.digitalocean.com/products/monitoring/
    17. [17]Reference for App Specification. DigitalOcean Documentation. https://docs.digitalocean.com/products/app-platform/reference/app-spec/
    18. [18]Simple, predictable pricing. DigitalOcean. https://www.digitalocean.com/pricing
    19. [19]doctl. GitHub. https://github.com/digitalocean/doctl
    20. [20]godo (Go API client). GitHub. https://github.com/digitalocean/godo