API Documentation

Learn how to interact with the GenuxText API programmatically.

Introduction

The GenuxText API allows you to programmatically create and retrieve text snippets. All API endpoints return JSON responses unless otherwise specified.

Base URL

https://text.ceylonnet.com/api

Content Type

application/json

API Endpoints

Create a New Text

POST /api/texts

Request Body

{
  "title": "Your Text Title",
  "content": "Your text content goes here"
}

Example using cURL

curl -X POST https://text.ceylonnet.com/api/texts \
  -H "Content-Type: application/json" \
  -d '{"title":"API Test","content":"This text was created via API"}'

Response

{
  "success": true,
  "id": "text_id",
  "text": {
    "content": "This text was created via API",
    "title": "API Test",
    "_id": "text_id",
    "createdAt": "2023-08-15T12:34:56.789Z"
  },
  "links": {
    "view": "https://text.ceylonnet.com/text/text_id",
    "raw": "https://text.ceylonnet.com/api/texts?id=text_id&raw=true",
    "api": "https://text.ceylonnet.com/api/texts?id=text_id"
  }
}

Get a Text

GET /api/texts?id=text_id

Parameters

id required

The ID of the text to retrieve

raw optional

Set to true to get raw text content instead of JSON

Example using cURL

curl https://text.ceylonnet.com/api/texts?id=text_id

Error Handling

When an error occurs, the API will return a JSON response with success: false and an error message:

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

Common Error Codes

400
Bad Request
Missing required parameters
404
Not Found
Text not found
500
Server Error
Internal server error

Integration Examples

JavaScript

// Create a new text
async function createText(title, content) {
  const response = await fetch('https://text.ceylonnet.com/api/texts', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ title, content }),
  });
  
  return response.json();
}

Python

import requests

# Create a new text
def create_text(title, content):
    url = 'https://text.ceylonnet.com/api/texts'
    payload = {
        'title': title,
        'content': content
    }
    response = requests.post(url, json=payload)
    return response.json()