Skip to content

adarshrkumar/nanoid-api

Repository files navigation

nanoid-api

A simple API service for generating unique nanoid identifiers.

API Endpoints

GET /api or POST /api

Generates a unique nanoid.

Query Parameters:

  • ids (optional): Comma-separated list of existing IDs to avoid collisions

Response:

{
  "id": "V1StGXR8_Z5jdHi6B-myT"
}

Example Usage

// Generate a new ID
const response = await fetch('/api');
const { id } = await response.json();

// Generate an ID that doesn't collide with existing ones
const existingIds = ['abc123', 'def456'];
const response = await fetch(`/api?ids=${existingIds.join(',')}`);
const { id } = await response.json();

Tech Stack

Development

npm install
npm run dev

Deployment

npm run build

About

An Astro-based API service for generating unique nanoid identifiers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors