kv
KV
Cloudflare API for KV data storage written in Crystal.
Installation
-
Add the dependency to your
shard.yml:dependencies: kv: github: joseafga/kv -
Run
shards install
Usage
require "kv"
# Credentials
client = KV::Client.new("YOUR_CLOUDFLARE_ACCOUNT_ID", "YOUR_CLOUDFLARE_API_TOKEN")
# Create a namespace
namespace = client.create "My Namespace"
client.get namespace.id do |ns|
ns.write("foo", "bar") # create a key-value
ns.keys.each { |key| puts key.name } # list all the keys
end
Error handling
begin
namespace.read "bad-key"
rescue ex : KV::ResponseError
puts ex.message # => "Error 10009: get: 'key not found'."
namespace.write("bad-key", "default value")
end
See spec/kv_spec.cr for more examples.
Contributing
- Fork it (https://github.com/joseafga/kv/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- José Almeida - creator and maintainer
Repository
kv
Owner
Statistic
- 0
- 0
- 0
- 0
- 0
- about 4 hours ago
- November 30, 2025
License
MIT License
Links
Synced at
Wed, 10 Jun 2026 22:10:26 GMT
Languages