Documentation
DressAPI documentation: getting started, API reference, authentication, CRUD operations, URL parameters, response structure, and database conventions.
Getting Started
1. Install with Composer
$ composer require dressapi/core
2. Configure Your Database
config.php
define('DB_HOST', 'localhost'); define('DB_NAME', 'your_database'); define('DB_USERNAME', 'your_user'); define('DB_PASSWORD', 'your_password');Point your web server DocumentRoot to the www/ directory and your API is ready.
Authentication
Login and Get JWT Token
Login Request
curl -X POST https://api.example.com/sign
-d "dusername=admin&dpassword=admin"
Response
{
"token": "eyJhbGciOiJIUzI1NiIs...",
"user": {
"id": 1,
"username": "admin",
"role": "admin"
}
}
Use Token in Requests
Authenticated Request
curl
-H "Authorization: Bearer YOUR_TOKEN"
-X GET https://api.example.com/product
For HTML pages, session-based authentication is used automatically when the Accept header is text/html. Add site_mode=1 to forms if you need session auth with JSON.
CRUD Operations
| Method | URL | Description | Example |
|---|---|---|---|
| GET | /table |
List all records | GET /product |
| GET | /table/id |
Read single record | GET /product/42 |
| GET | /table/full |
Read with relations | GET /product/full |
| POST | /table |
Create record | POST /product -d "dname=Shirt" |
| PUT | /table/id |
Update record | PUT /product/42 -d "dprice=24.99" |
| DELETE | /table/id |
Delete record | DELETE /product/42 |
URL Parameters
| Parameter | Syntax | Example | Description |
|---|---|---|---|
| With Relations | /full |
/product/full |
Include data from related tables |
| Pagination | /p/page,perpage |
/product/p/1,10 |
Page number and items per page |
| Order By | /ob/field[-DESC] |
/product/ob/price-DESC |
Sort by field, optionally descending |
| Equals | /field=value |
/product/status=active |
Exact match filter |
| Contains | /field~value |
/product/name~shirt |
Partial match (LIKE) filter |
| Comparison | /field>value |
/product/price>10 |
Greater than, less than, etc. |
Response Structure
Successful Response
JSON Response
{
"items": [
{
"id": 1,
"name": "Blue Shirt",
"price": 29.99,
"category": {
"id": 3,
"name": "Clothing"
}
}
],
"total": 42,
"page": 1,
"per_page": 10
}
Output Formats
The response format is determined by the Accept header:
Accept Headers
application/json # JSON (default)
application/xml # XML
text/html # HTML (CMS mode)
text/plain # Plain text
Database Conventions
| Convention | Pattern | Example |
|---|---|---|
| Primary key | id |
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY |
| Foreign key | id_{table} |
id_category INT UNSIGNED |
| Framework tables | _{name} |
_user, _role, _acl, _translation |
| Password fields | *pwd* / *password* |
user_pwd, password |
| Image fields | *_img |
profile_img, cover_img |
| File fields | *file* |
document_file, filename |
| Email fields | *email* |
user_email, email |
API Documentation
Auto-generated documentation from DressAPI Core source code: