REST API for Opensource
IceHrm exposes employee details and attendance data through a REST API. For complete API documentation, see the API Docs section.
Server Configuration
Nginx Configuration
All requests to /app/api/ must redirect to /app/index.php. Add this location block to your Nginx configuration:
location /app/api/ {
try_files $uri /app/api/index.php?/$uri&$args;
}
For non-root installations (e.g., your-site.com/icehrm):
location /icehrm/app/api/ {
try_files $uri /icehrm/app/api/index.php?/$uri&$args;
}
Apache Configuration
For Apache (XAMPP, WAMPP), a .htaccess file is included in icehrm/app/api to handle API request redirection automatically. No additional configuration is required.
Enabling the REST API
- Log in to IceHrm as an administrator
- Navigate to Settings -> Other
- Find Enable REST Api and set it to Yes
- Save the settings
Testing the API
To verify the REST API is working correctly:
- Open your browser
- Visit
http://your-icehrm-url.com/app/api/echo - You should see an echo response with a random number
If you see the echo response, the API is configured correctly.
API Usage
Base URL: http://your-icehrm-url.com/app/api
Example Request
To call the /employees/me endpoint, send a request to:
http://your-icehrm-url.com/app/api/employees/me
Using cURL
curl -X GET \
-H "Authorization: Bearer [your-token]" \
-H "Content-Type: application/json" \
"http://your-icehrm-url.com/app/api/employees/me"
API Documentation
For complete API documentation including all available endpoints, request/response formats, and authentication details, see:
- API Docs Overview - Authentication and response formats
- Employees API - Employee management endpoints
- Attendance API - Attendance and punch in/out endpoints
- Leave API - Leave request endpoints
- Documents API - Employee document endpoints