A caching resolver service for VOI (.voi) names and addresses.
GET /api/name/[address]?ignoreCache=false
Resolves an Algorand address to its corresponding VOI name. For multiple addresses, use comma-separated values.
Parameters:
address
(string): The Algorand address to resolve, or multiple comma-separated addresses (max 50)ignoreCache
(boolean, optional): Skip cache lookup (default: false)
Examples:
GET /api/name/ADDRESS1
GET /api/name/ADDRESS1,ADDRESS2,ADDRESS3
Response:
{
"results": [
{
"address": "ADDRESS1",
"name": "example.voi",
"cached": true
}
]
}
GET /api/address/[name]?ignoreCache=false
Resolves a VOI name to its corresponding Algorand address. For multiple names, use comma-separated values.
Parameters:
name
(string): The VOI name to resolve (must end in .voi), or multiple comma-separated names (max 50)ignoreCache
(boolean, optional): Skip cache lookup (default: false)
Examples:
GET /api/address/name1.voi
GET /api/address/name1.voi,name2.voi,name3.voi
Response:
{
"results": [
{
"name": "name1.voi",
"address": "R7TBR3Y5QCM6Y2OPQP3BPNUQG7TLN75IOC2WTNRUKO4VPNSDQF52MZB4ZE",
"cached": true
}
]
}
POST /api/name
Request Body:
{
"addresses": ["ADDRESS1", "ADDRESS2", ...],
"ignoreCache": false
}
Parameters:
addresses
(string[]): Array of Algorand addresses (max 50)ignoreCache
(boolean, optional): Skip cache lookup (default: false)
POST /api/address
Request Body:
{
"names": ["name1.voi", "name2.voi", ...],
"ignoreCache": false
}
Parameters:
names
(string[]): Array of VOI names (max 50)ignoreCache
(boolean, optional): Skip cache lookup (default: false)
Batch Response Format:
{
"results": [
{
"address": "...", // or "name" for name lookups
"name": "example.voi", // or "address" for address lookups
"cached": true
}
// ... more results
]
}
{
"error": "Name/Address parameter is required"
}
{
"error": "Name/Address not found"
}
{
"error": "Internal server error"
}
The API implements a dual-cache system with the following features:
- Separate caches for name-to-address and address-to-name lookups
- Results are cached for 1 hour by default, including not-found responses
- Cache can be bypassed using
ignoreCache=true
- When bypassing cache, the service will still update both caches with fresh values
- Bidirectional caching: when a name or address is resolved, both caches are updated
- Null values are cached to prevent repeated lookups of non-existent names/addresses
- Cache status is indicated in the
X-Cache
header:HIT
: Served from cacheMISS
: Freshly resolvedBYPASS
: Cache was ignoredMIXED
: For batch requests with mixed cache results
- Primary key:
name
(lowercase) - Stores name-to-address mappings
- Handles multiple names pointing to the same address
- Null addresses indicate non-existent names
- Schema:
CREATE TABLE name_cache ( name TEXT PRIMARY KEY, address TEXT NULL, -- NULL indicates name not found updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP );
- Constraints:
- Name format: Must match
^[a-z0-9-]+\.voi$
- Address format: Must match
^[A-Z2-7]{58}$
when not null
- Name format: Must match
- Indexes:
- Primary key on
name
- Secondary index on
address
- Primary key on
- Primary key:
address
- Stores address-to-name mappings
- Maintains the canonical name for each address
- Null names indicate non-existent addresses
- Schema:
CREATE TABLE address_cache ( address TEXT PRIMARY KEY, name TEXT NULL, -- NULL indicates address not found updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP );
- Constraints:
- Address format: Must match
^[A-Z2-7]{58}$
- Name format: Must match
^[a-z0-9-]+\.voi$
when not null
- Address format: Must match
- Indexes:
- Primary key on
address
- Secondary index on
name
- Primary key on
The API implements the following security measures:
The API has a permissive CORS policy that allows:
- Origins:
*
(all origins) - Methods:
GET
,POST
,OPTIONS
- Headers:
Content-Type
The cache tables implement Row Level Security (RLS) with the following policies:
- Public read access is allowed for all records
- Write access (insert/update) is restricted to the service role
- No delete access is provided
- Batch requests are limited to 50 items per request
- Individual requests are processed sequentially
Required environment variables:
PUBLIC_SUPABASE_URL=your_supabase_url
PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
- Clone the repository
- Install dependencies:
npm install
- Create a
.env
file with the required environment variables - Run the development server:
npm run dev
The API is designed to be deployed on Vercel using the SvelteKit adapter. Simply push to your repository and Vercel will handle the deployment automatically.