Web Services – Custom Tables

Overview #

This plugin extends Joomla’s web services capabilities by adding API endpoints for Custom Tables integration. It enables secure API access to Custom Tables data and functionality through RESTful endpoints.

Prerequisites #

  • Joomla 4.0 or higher
  • Custom Tables component installed
  • Web Services – Custom Tables plugin activated
  • API Authentication plugin activated

Authentication #

All endpoints require authentication using:

  • API Key in the X-API-Key header
  • Bearer token in the Authorization header (obtained via login)

API Endpoints #

Login #

Authenticates a user and returns a bearer token for subsequent requests.

POST /api/index.php/v1/customtables/login
Headers:
  Content-Type: application/json
  X-API-Key: YOUR-API-KEY
Body:
{
    "username": "joe",
    "password": "SecurePassword123"
}

CURL example

curl -X POST http://localhost/api/index.php/v1/customtables/login -H 'Content-Type: application/json' -d '{ "username": "joe",  "password": "SecurePassword123"}' -H 'X-API-Key: YOUR-API-KEY'

Logout #

Invalidates the current authentication token.

GET /api/index.php/v1/customtables/logout
Headers:
  Authorization: Bearer TOKEN
  X-API-Key: YOUR-API-KEY

Register #

Creates a new user account.

Allow Registration: Enable or disable user registration through the API

POST /api/index.php/v1/customtables/register
Headers:
  Authorization: Bearer TOKEN
  X-API-Key: YOUR-API-KEY
Body:
{
    "name": "Joe Smith",
    "username": "joe",
    "email": "joe@example.com",
    "password": "SecurePassword123",
    "password_confirm": "SecurePassword123"
}

Record Management #

Get Single Record #

Retrieves a specific record using a layout template.

GET /api/index.php/v1/customtables/record
Parameters:
  layout: LAYOUT_NAME
  id: RECORD_ID
Headers:
  Authorization: Bearer TOKEN
  X-API-Key: YOUR-API-KEY

Get Multiple Records #

Retrieves multiple records using a layout template.

GET /api/index.php/v1/customtables/records
Parameters:
  layout: LAYOUT_NAME
Headers:
  Authorization: Bearer TOKEN
  X-API-Key: YOUR-API-KEY

Get Edit Form #

Retrieves form fields and parameters for editing a record.

GET /api/index.php/v1/customtables/edit
Parameters:
  layout: LAYOUT_NAME
  id: RECORD_ID (optional)
Headers:
  Authorization: Bearer TOKEN
  X-API-Key: YOUR-API-KEY

Submit Edit Form #

Creates or updates a record.

POST /api/index.php/v1/customtables/edit
Parameters:
  layout: LAYOUT_NAME
  id: RECORD_ID (optional - omit for new records)
Headers:
  Authorization: Bearer TOKEN
  X-API-Key: YOUR-API-KEY
Body:
  Form fields as JSON

CORS Configuration #

Add the following configuration to your Apache .htaccess file or server configuration to enable CORS:

    SetEnvIf Origin "^http(s)?://your-domain.com(:[0-9]+)?$" ORIGIN=$0

    Header always set Access-Control-Allow-Origin "%{ORIGIN}e" env=ORIGIN
    Header always set Access-Control-Allow-Credentials "true"
    Header always set Access-Control-Allow-Methods "OPTIONS, GET, POST, PUT, DELETE"
    Header always set Access-Control-Allow-Headers "Content-Type, X-Requested-With, X-Joomla-Token, Authorization, X-API-Key"
    Header always set Access-Control-Max-Age "3600"

    Header append Vary "Origin"
    Header append Vary "Access-Control-Request-Method"
    Header append Vary "Access-Control-Request-Headers"

Replace your-domain.com with your actual domain name.


What are your feelings

Leave a Reply

Updated on February 18, 2025