Back to Home
Documentation
Documentation/API Reference
API Documentation

API Reference

Complete REST API documentation for KmerHosting services

Secure Authentication

NextAuth-based session authentication with rate limiting

RESTful Design

Clean, predictable endpoints following REST principles

JSON Responses

Consistent JSON format with success/error handling

Base URL

https://kmerhosting.com/api

Authentication

Most endpoints require authentication via session cookies (NextAuth). After logging in, the session is maintained automatically.

// Login request
POST /api/user/auth/login
Content-Type: application/json

{
  "email": "[email protected]",
  "password": "YourSecurePassword123!"
}

// Response
{
  "success": true,
  "data": {
    "user": {
      "id": "uuid",
      "email": "[email protected]",
      "customerId": "KH-XXXXXX"
    }
  }
}

Response Format

Success Response

{
  "success": true,
  "data": {
    // Response data here
  }
}

Error Response

{
  "success": false,
  "error": "Error message description"
}

HTTP Status Codes

CodeMeaning
200Success - Request completed successfully
201Created - Resource created successfully
400Bad Request - Invalid request parameters
401Unauthorized - Authentication required
403Forbidden - Insufficient permissions
404Not Found - Resource doesn't exist
429Too Many Requests - Rate limit exceeded
500Internal Server Error - Server error

API Endpoints

Authentication

POST
/api/user/auth/register

Create new account

POST
/api/user/auth/login

Authenticate user

POST
/api/user/auth/logout

End session

POST
/api/user/auth/verify

Verify email

Cart & Orders

GET
/api/cart

Get cart items

POST
/api/cart/add

Add to cart

POST
/api/checkout

Process checkout

GET
/api/orders/[id]

Get order details

Payments

POST
/api/orders/[id]/pay

Pay order

GET
/api/credits/balance

Get credit balance

POST
/api/credits/add

Add credits

Services

GET
/api/user/shared-hosting

List shared hosting

GET
/api/user/vps

List VPS servers

GET
/api/user/wordpress-hosting

List WordPress hosting

Rate Limiting

To ensure fair usage, our API implements rate limiting on authentication endpoints:

  • Login: 5 attempts per 15 minutes per IP
  • Registration: 3 attempts per hour per IP
  • Password Reset: 3 attempts per hour per IP

Full API Documentation

For complete API documentation with detailed examples, see our comprehensive guide.

View Complete API Docs