Cuid Generator API - Ruby Gem
Cuid Generator is a tool for generating collision-resistant unique identifiers (Cuids). Cuids are optimized for horizontal scaling and sequential lookup performance in distributed systems.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_cuidgenerator'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_cuidgenerator
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_cuidgenerator'
# Initialize the client
client = APIVerve::Cuidgenerator::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({ count: 1 })
# Print the response
puts response
Error Handling
begin
response = client.execute({ count: 1 })
puts response["data"]
rescue APIVerve::Cuidgenerator::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Cuidgenerator::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Cuidgenerator::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"cuids": [
"cmj95ed27000000145v116use",
"cmj95ed2700010014uuounuyc",
"cmj95ed27000200147pwbz35y",
"cmj95ed27000300142h9ivqrz",
"cmj95ed27000400149ingh73n",
"cmj95ed2700050014mg9alsah",
"cmj95ed27000600149utx0fy3",
"cmj95ed270007001467kspfhp",
"cmj95ed2700080014n7ykgwxf",
"cmj95ed2700090014rrnfehcn"
],
"count": 10,
"format": "c + timestamp + counter + fingerprint + random",
"collision_resistant": true,
"sortable": true
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/cuidgenerator?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.