ContentAPI Manual

A complete guide to using AutoManual

Keywords: guide, AutoManual, documentation, technical manuals

Overview

ContentAPI provides an easy-to-use API for managing and sharing Markdown files via HTTP. It supports functionalities such as listing files, retrieving file content, and viewing help documentation.

Endpoints

1. /contentapi.php?action=list

Description: Lists available Markdown files in the specified folder.

Parameters:

Example Request:

GET https://ezetxt.com/contentapi.php?action=list&page=1&limit=5&sort=title&order=asc

Example Response:

{
  "files": [
    {
      "filename": "example.md",
      "title": "Example",
      "description": "This is an example manual.",
      "keywords": "example, manual",
      "url": "https://ezetxt.com/messages/example.md",
      "last_modified": "2024-11-26 14:35:20",
      "size": "2.5 KB"
    }
  ],
  "total": 1,
  "page": 1,
  "limit": 5,
  "sort": "title",
  "order": "asc",
  "search": ""
}

2. /contentapi.php?action=get

Description: Retrieves the content of a specific Markdown file.

Parameters:

Example Request:

GET https://ezetxt.com/contentapi.php?action=get&file=example

Example Response:

{
  "filename": "example.md",
  "title": "Example", 
  "description": "This is an example manual.",
  "keywords": "example, manual",
  "content": "# Example Manual\nThis is the content of the example manual."
}

3. /contentapi.php?action=help

Description: Provides information about all available API endpoints.

Example Request:

GET https://ezetxt.com/contentapi.php?action=help

Example Response:

{
  "endpoints": {
    "/contentapi.php?action=list&page={page}&limit={limit}&search={term}&sort={field}&order={asc|desc}": "List markdown files with pagination, sorting, and search.",
    "/contentapi.php?action=get&file={filename}": "Get the content of a specific markdown file.",
    "/contentapi.php?action=help": "Get help information about API endpoints."
  },
  "parameters": {
    "page": "Pagination page number (default: 1)",
    "limit": "Number of results per page (default: 10)", 
    "search": "Filter results by a search term",
    "sort": "Field to sort by (filename, title, or last_modified)", 
    "order": "Sort order (asc or desc)",
    "type": "File type filter (default: md)"
  }
}

Configuration

Example Configuration:

define('RATE_LIMIT', 100);
define('RATE_LIMIT_PERIOD', 3600);
$content_folder = '/messages/';

Advanced Features

Rate Limiting

Limits the number of requests a client can make in a specific time period.

CORS

Enables cross-domain access. By default, CORS headers allow access from all origins.

Example Implementation:

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, OPTIONS'); 
header('Access-Control-Allow-Headers: Content-Type');

Error Handling

The API returns appropriate HTTP status codes and JSON error messages for invalid requests.

Example Error Response:

{
  "error": "File not found."
}

Contact

For support or inquiries, visit LogicEverything.


Reset to Default Theme

Home