dressapi / api
DressAPI API - REST API layer built on DressAPI Core.
3.0.8
2026-05-06 07:58 UTC
Requires
- php: >=8.1
- dressapi/core: ^3.0.8
README
DressAPI API is a pure REST API implementation built on DressAPI Core. It exposes your database as a JSON API with zero boilerplate — designed to be consumed by decoupled frontends such as Vue, React, Angular, or any HTTP client.
It is also used by DressAPI CMS to power select elements (picklists) for related tables in the admin interface.
License: Apache 2.0 · Author: Tufano Pasquale · Version: 3.0.6
What distinguishes API from CMS
| DressAPI API | DressAPI CMS | |
|---|---|---|
| Output | JSON (default), XML, plain text | HTML (server-side rendered) |
| Authentication | JWT only | JWT + cookie sessions |
| Frontend | External (Vue, React, Angular, AJAX) | Included (template engine) |
| Use case | Headless / decoupled architecture | Integrated CMS |
Requirements
| Component | Minimum | Notes |
|---|---|---|
| PHP | 8.1 | Extensions: pdo_mysql, curl, mbstring, json |
| MySQL | 5.7 | Or MariaDB >= 10.3 |
| Apache | 2.4 | mod_rewrite required |
| Composer | 2.x |
Installation
Via Composer
composer require dressapi/api
Via Git
git clone https://git.dressapi.com/dressapi/api.git
cd api
composer install
Configuration
Copy config.php.sample to config.php and edit:
<?php
define('DOMAIN_NAME', 'yourdomain.com');
define('APP_NAME', 'myapp');
define('APP_ENV', 'production'); // develop | stage | production
// IMPORTANT: change before going to production
define('TOKEN_SECRET_KEY', 'your-unique-jwt-secret');
define('PWD_CRYPT', 'your-unique-crypt-key');
// Database
define('DB_HOST', 'localhost');
define('DB_PORT', 3306);
define('DB_NAME', 'mydb');
define('DB_USERNAME', 'myuser');
define('DB_PASSWORD', 'mypassword');
Database Setup
mysql -u root -p -e "CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
mysql -u root -p mydb < _SETUP/dressapi_cms.sql
Default admin credentials (change immediately in production):
| Role | Password | |
|---|---|---|
| Admin | admin@dressapi.com | admin |
Apache Configuration
sudo cp _SETUP/api.dressapi.com.conf /etc/apache2/sites-available/
sudo a2ensite api.dressapi.com
sudo systemctl reload apache2
Authentication
Login
curl -X POST https://yourapi.com/sign \
-d "dusername=admin&dpassword=yourpassword"
Response:
{
"token": "eyJ0eXAiOiJKV1Qi..."
}
Authenticated requests
curl -H "Authorization: Bearer <token>" \
-X GET https://yourapi.com/article
API Reference
HTTP Methods
| Method | Action |
|---|---|
GET | Read one or more records |
POST | Insert a new record |
PUT | Full update of a record |
PATCH | Partial update of a record |
DELETE | Delete a record |
OPTIONS | Return field types and allowed methods |
URL Parameters
| Parameter | Short | Example | Description |
|---|---|---|---|
full | full | /article/full | Resolve foreign keys to human-readable values |
page | p | /article/p/2 | Page 2 (default: 20 items per page) |
/article/p/2,10 | Page 2, 10 items per page | ||
order-by | ob | /article/ob/title | Order by field ASC |
/article/ob/id-DESC | Order by field DESC |
Filters
Append {field}{operator}{value} to the path:
| Operator | Meaning |
|---|---|
= | Equals |
< > >= <= | Comparison |
~ | Contains (LIKE) |
Examples
# Read with relations, ordered, paginated
curl -H "Authorization: Bearer <token>" \
-X GET "https://yourapi.com/article/full/ob/id-DESC/p/1,10"
# Filter: articles by user, containing "hello" in title
curl -H "Authorization: Bearer <token>" \
-X GET "https://yourapi.com/article/id_user=1/title~hello"
# Insert
curl -H "Authorization: Bearer <token>" \
-X POST https://yourapi.com/article \
-d "title=Hello&body=Content&id_user=1"
# Partial update
curl -H "Authorization: Bearer <token>" \
-X PATCH https://yourapi.com/article/1 \
-d "title=Updated"
# Delete
curl -H "Authorization: Bearer <token>" \
-X DELETE https://yourapi.com/article/1
Output Formats
-H 'Accept: application/json' # default
-H 'Accept: application/xml'
-H 'Accept: text/plain'
Related Projects
| Project | Description |
|---|---|
| dressapi/core | Framework core library |
| dressapi/cms | Server-side CMS (uses this API for picklists) |
| dressapi/vue | Vue 3 frontend |
| dressapi/react | React frontend |
| dressapi/angular | Angular frontend |
| dressapi/ajax | Vanilla JS frontend |
License
Apache 2.0 — free for personal and commercial use.