BASICHUB Logo

BASICHUB Playground — API

never late to elevate · Simple mock-style endpoints for quick prototyping

About this Playground

A minimal REST API implemented on Cloudflare Workers. Use it to test client apps, demos, and coursework. Responses are ephemeral and randomly generated.

TailwindCSS Mock Data CORS Enabled

Endpoints

All responses are application/json. CORS is open for testing. Routes include the intentionally misspelled /register.

POST

/register

Register a user. If both username and password are provided, returns random user data.

Body (JSON)
  • username — string (required)
  • password — string (required)
cURL
curl -X POST "$BASE/register" \
  -H "Content-Type: application/json" \
  -d '{"username":"alice","password":"s3cret"}'
Response
{
  "success": true,
  "user": {
    "id": "kspm8t-2a4q9y1",
    "username": "alice",
    "token": "<random>",
    "createdAt": "2025-01-01T00:00:00.000Z"
  }
}
POST

/login

Login with username and password. Returns a random token.

cURL
curl -X POST "$BASE/login" \
  -H "Content-Type: application/json" \
  -d '{"username":"alice","password":"s3cret"}'
GET

/profile

Returns one randomly chosen profile.

curl "$BASE/profile"
GET

/profile/:id

Returns a profile with the requested id and a random name.

curl "$BASE/profile/abc123"
GET

/get

Echo service: returns all query params, request headers, timestamp, method and path.

curl "$BASE/get?foo=bar&num=123" -H "X-Test: abc"
Sample response
{
  "success": true,
  "timestamp": "2025-10-13T15:03:22.105Z",
  "method": "GET",
  "path": "/get",
  "query": { "foo": "bar", "num": "123" },
  "headers": { "x-test": "abc", "accept": "*/*" }
}

Quick JS Examples

Fetch: Register

const BASE = document.getElementById('baseUrl').value;
const res = await fetch(`${BASE}/register`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ username: 'alice', password: 's3cret' })
});
const data = await res.json();
console.log(data);

Fetch: GET /get

const BASE = document.getElementById('baseUrl').value;
const res = await fetch(`${BASE}/get?foo=bar&num=123`, {
  headers: { 'X-Test': 'abc' }
});
console.log(await res.json());