kvrest.dev

Simplified Key-Value Storage with Telegram Integration

Start Using on Telegram API Documentation View on GitHub

Why kvrest.dev?

If you're tired of dealing with MongoDB, PostgreSQL, and other heavyweight databases for your small projects, kvrest.dev is here for you. The project focuses on simplicity to make coding fun again.

Get Started

  1. Start the Telegram Bot: Launch kvrest_bot
  2. Send Command: Type and send `/start` in the bot to create your key-value store.

Telegram Bot Commands

📚 /help

Displays the documentation for all available commands.

🏗️ /start

Creates a new key-value store. A unique API key and BoltDB file are generated.

🔑 /change_api_key

Changes your existing API key. A new key is generated, and the BoltDB file is updated.

🔍 /view_bucket_keys

View the keys stored in a specific bucket. Provide the bucket name.

📋 /list_buckets

Lists all the buckets created in your key-value store.

📥 /download_kv

Download your entire key-value store as a BoltDB file.

API Endpoints

Create a New Bucket

PUT /api/{bucketName}

Parameters:

  • bucketName (required, string): Name of the bucket to create

Responses:

  • 200: Bucket created successfully
  • 405: Bucket name 'system' not allowed
  • 500: Internal Server Error

Example cURL:

curl -X PUT -H "API-KEY: your_api_key" https://kvrest.dev/api/yourBucketName

Delete an Existing Bucket

DELETE /api/{bucketName}

Parameters:

  • bucketName (required, string): Name of the bucket to delete

Responses:

  • 200: Bucket deleted successfully
  • 500: Internal Server Error

Example cURL:

curl -X DELETE -H "API-KEY: your_api_key" https://kvrest.dev/api/yourBucketName

List All Buckets

POST /buckets

Responses:

  • 200: Returns a list of all buckets in JSON format. Example: {"buckets": ["example-buckets1", "example-buckets2"]}
  • 500: Internal Server Error

Example cURL:

curl -X POST -H "API-KEY: your_api_key" https://kvrest.dev/api/buckets

Create/Update a Key-Value Pair

PUT /api/{bucketName}/{key}

Parameters:

  • bucketName (required, string): Name of the bucket
  • key (required, string): Name of the key within the bucket
  • Body (JSON): {"foo": "bar"}

Responses:

  • 200
  • 400: Bad Request
  • 500: Internal Server Error

Example cURL:

curl -X PUT -H "API-KEY: your_api_key" -H "Content-Type: application/json" --data '{"key": "value"}' https://kvrest.dev/api/yourBucketName/yourKey

Retrieve a Value for a Key

GET /api/{bucketName}/{key}

Parameters:

  • bucketName (required, string): Name of the bucket
  • key (required, string): Name of the key within the bucket

Responses:

  • 200: JSON object representing the value
  • 404: Key not found
  • 500: Internal Server Error

Example cURL:

curl -X GET -H "API-KEY: your_api_key" https://kvrest.dev/api/yourBucketName/yourKey

Delete a Key-Value Pair

DELETE /api/{bucketName}/{key}

Parameters:

  • bucketName (required, string): Name of the bucket
  • key (required, string): Name of the key within the bucket

Responses:

  • 200
  • 500: Internal Server Error

Example cURL:

curl -X DELETE -H "API-KEY: your_api_key" https://kvrest.dev/api/yourBucketName/yourKey

List All Keys in a Bucket

GET /api/{bucketName}

Parameters:

  • bucketName (required, string): Name of the bucket to list keys from

Responses:

  • 200: Returns a list of all keys in the specified bucket in JSON format. Example: {"keys": ["example-key1", "example-key2"]}
  • 404: Bucket not found
  • 500: Internal Server Error

Example cURL:

curl -X GET -H "API-KEY: your_api_key" https://kvrest.dev/api/yourBucketName

Migrate to Your Server

Download db file from bot /download_db.

mkdir -p ./kvrest && cp /file/from-bot/file.db ./kvrest/
cd ./kvrest/
docker run --rm -it -p 8080:8080 -v ${PWD}:/app/data ghcr.io/split174/kvrest:v1.0.1