DEV Community

Alex Spinov
Alex Spinov

Posted on

TiDB Has a Free API — MySQL-Compatible Distributed Database

TiDB is an open-source, MySQL-compatible, distributed SQL database. It scales horizontally like NoSQL but keeps ACID transactions and MySQL syntax.

What Is TiDB?

TiDB (Ti = Titanium) separates compute and storage, scaling each independently. It handles OLTP and OLAP workloads simultaneously (HTAP).

Free tier (TiDB Serverless):

  • 25GB row storage
  • 25GB columnar storage
  • 250M RUs/month

Quick Start

# TiDB Serverless — connect with any MySQL client
mysql -u YOUR_USER -p -h gateway01.us-east-1.prod.aws.tidbcloud.com -P 4000 --ssl-mode=VERIFY_IDENTITY
Enter fullscreen mode Exit fullscreen mode

MySQL-Compatible API

CREATE TABLE products (
  id BIGINT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(255),
  price DECIMAL(10,2),
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO products (name, price) VALUES ("Widget", 9.99);

-- HTAP: same table, analytical query
SELECT DATE(created_at) as day, SUM(price) as revenue
FROM products
GROUP BY day
ORDER BY day DESC;
Enter fullscreen mode Exit fullscreen mode

REST API (TiDB Cloud)

# Data API (serverless)
curl -X POST https://REGION.data.tidbcloud.com/api/v1beta/app/CLUSTER_ID/endpoint/SQL \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"sql":"SELECT * FROM products LIMIT 10"}'
Enter fullscreen mode Exit fullscreen mode

Use Cases

  1. MySQL migration — zero code changes
  2. Horizontal scaling — grow without sharding
  3. Real-time analytics — OLTP + OLAP
  4. Financial systems — distributed ACID
  5. Multi-cloud — run anywhere

Need web data at scale? Check out my scraping tools on Apify or email spinov001@gmail.com for custom solutions.

Top comments (0)