This document provides comprehensive documentation for the Filadex API endpoints. The API allows you to manage filaments, materials, colors, manufacturers, and other resources in the Filadex application.
- Authentication
- Filaments
- Materials
- Colors
- Manufacturers
- Diameters
- Storage Locations
- User Management
- Sharing
- Statistics
- Theme
Authenticates a user and returns a JWT token as a cookie.
- URL:
/api/auth/login - Method:
POST - Authentication: None
- Request Body:
{ "username": "string", "password": "string" } - Response:
200 OK{ "id": "number", "username": "string", "isAdmin": "boolean" } - Error Responses:
401 Unauthorized: Invalid credentials500 Internal Server Error: Server error
Logs out the current user by clearing the authentication cookie.
- URL:
/api/auth/logout - Method:
POST - Authentication: Required
- Response:
204 No Content - Error Responses:
500 Internal Server Error: Server error
Returns information about the currently authenticated user.
- URL:
/api/auth/me - Method:
GET - Authentication: Required
- Response:
200 OK{ "id": "number", "username": "string", "isAdmin": "boolean", "forceChangePassword": "boolean", "language": "string", "createdAt": "string", "lastLogin": "string" } - Error Responses:
401 Unauthorized: Not authenticated404 Not Found: User not found500 Internal Server Error: Server error
Changes the password for the currently authenticated user.
- URL:
/api/auth/change-password - Method:
POST - Authentication: Required
- Request Body:
{ "currentPassword": "string", "newPassword": "string" } - Response:
200 OK{ "message": "Password changed successfully" } - Error Responses:
400 Bad Request: Validation error401 Unauthorized: Incorrect current password500 Internal Server Error: Server error
Returns all filaments for the authenticated user.
- URL:
/api/filaments - Method:
GET - Authentication: Required
- Query Parameters:
export: (optional) If set to 'csv' or 'json', returns the filaments in the specified format
- Response:
200 OK[ { "id": "number", "userId": "number", "name": "string", "manufacturer": "string", "material": "string", "colorName": "string", "colorCode": "string", "diameter": "string", "printTemp": "string", "totalWeight": "string", "remainingPercentage": "string", "purchaseDate": "string", "purchasePrice": "string", "status": "string", "spoolType": "string", "dryerCount": "number", "lastDryingDate": "string", "storageLocation": "string", "createdAt": "string", "updatedAt": "string" } ] - Error Responses:
401 Unauthorized: Not authenticated500 Internal Server Error: Failed to fetch filaments
Returns a specific filament by ID.
- URL:
/api/filaments/:id - Method:
GET - Authentication: Required
- URL Parameters:
id: The ID of the filament
- Response:
200 OK{ "id": "number", "userId": "number", "name": "string", "manufacturer": "string", "material": "string", "colorName": "string", "colorCode": "string", "diameter": "string", "printTemp": "string", "totalWeight": "string", "remainingPercentage": "string", "purchaseDate": "string", "purchasePrice": "string", "status": "string", "spoolType": "string", "dryerCount": "number", "lastDryingDate": "string", "storageLocation": "string", "createdAt": "string", "updatedAt": "string" } - Error Responses:
400 Bad Request: Invalid filament ID401 Unauthorized: Not authenticated404 Not Found: Filament not found500 Internal Server Error: Failed to fetch filament
Creates a new filament.
- URL:
/api/filaments - Method:
POST - Authentication: Required
- Query Parameters:
import: (optional) If set to 'csv' or 'json', imports filaments from the provided data
- Request Body (for single filament):
{ "name": "string", "manufacturer": "string", "material": "string", "colorName": "string", "colorCode": "string", "diameter": "string", "printTemp": "string", "totalWeight": "number", "remainingPercentage": "number", "purchaseDate": "string", "purchasePrice": "number", "status": "string", "spoolType": "string", "dryerCount": "number", "lastDryingDate": "string", "storageLocation": "string" } - Request Body (for CSV import):
{ "csvData": "string" } - Request Body (for JSON import):
{ "jsonData": "string" } - Response (for single filament):
201 Created{ "id": "number", "userId": "number", "name": "string", "manufacturer": "string", "material": "string", "colorName": "string", "colorCode": "string", "diameter": "string", "printTemp": "string", "totalWeight": "string", "remainingPercentage": "string", "purchaseDate": "string", "purchasePrice": "string", "status": "string", "spoolType": "string", "dryerCount": "number", "lastDryingDate": "string", "storageLocation": "string", "createdAt": "string", "updatedAt": "string" } - Response (for import):
201 Created{ "created": "number", "duplicates": "number", "errors": "number" } - Error Responses:
400 Bad Request: Validation error401 Unauthorized: Not authenticated500 Internal Server Error: Failed to create filament
Updates an existing filament.
- URL:
/api/filaments/:id - Method:
PUT - Authentication: Required
- URL Parameters:
id: The ID of the filament
- Request Body:
{ "name": "string", "manufacturer": "string", "material": "string", "colorName": "string", "colorCode": "string", "diameter": "string", "printTemp": "string", "totalWeight": "number", "remainingPercentage": "number", "purchaseDate": "string", "purchasePrice": "number", "status": "string", "spoolType": "string", "dryerCount": "number", "lastDryingDate": "string", "storageLocation": "string" } - Response:
200 OK{ "id": "number", "userId": "number", "name": "string", "manufacturer": "string", "material": "string", "colorName": "string", "colorCode": "string", "diameter": "string", "printTemp": "string", "totalWeight": "string", "remainingPercentage": "string", "purchaseDate": "string", "purchasePrice": "string", "status": "string", "spoolType": "string", "dryerCount": "number", "lastDryingDate": "string", "storageLocation": "string", "createdAt": "string", "updatedAt": "string" } - Error Responses:
400 Bad Request: Invalid filament ID or validation error401 Unauthorized: Not authenticated404 Not Found: Filament not found500 Internal Server Error: Failed to update filament
Deletes a filament.
- URL:
/api/filaments/:id - Method:
DELETE - Authentication: Required
- URL Parameters:
id: The ID of the filament
- Response:
204 No Content - Error Responses:
400 Bad Request: Invalid filament ID401 Unauthorized: Not authenticated404 Not Found: Filament not found500 Internal Server Error: Failed to delete filament
Deletes multiple filaments at once.
- URL:
/api/filaments/batch - Method:
DELETE - Authentication: Required
- Request Body:
{ "ids": [1, 2, 3] } - Response:
200 OK{ "message": "Successfully deleted 3 filaments", "deletedCount": 3 } - Error Responses:
400 Bad Request: Invalid request format401 Unauthorized: Not authenticated500 Internal Server Error: Failed to delete filaments
Updates multiple filaments at once with the same values.
- URL:
/api/filaments/batch - Method:
PATCH - Authentication: Required
- Request Body:
{ "ids": [1, 2, 3], "updates": { "material": "PLA", "status": "opened", "remainingPercentage": 75 } } - Response:
200 OK{ "message": "Successfully updated 3 filaments", "updatedCount": 3 } - Error Responses:
400 Bad Request: Invalid request format401 Unauthorized: Not authenticated500 Internal Server Error: Failed to update filaments
Returns all materials.
- URL:
/api/materials - Method:
GET - Authentication: Required
- Query Parameters:
export: (optional) If set to 'csv', returns the materials in CSV format
- Response:
200 OK[ { "id": "number", "name": "string" } ] - Error Responses:
401 Unauthorized: Not authenticated500 Internal Server Error: Failed to fetch materials
Creates a new material.
- URL:
/api/materials - Method:
POST - Authentication: Required
- Query Parameters:
import: (optional) If set to 'csv', imports materials from the provided CSV data
- Request Body (for single material):
{ "name": "string" } - Request Body (for CSV import):
{ "csvData": "string" } - Response (for single material):
201 Created{ "id": "number", "name": "string" } - Response (for import):
201 Created{ "created": "number", "duplicates": "number", "errors": "number" } - Error Responses:
400 Bad Request: Validation error401 Unauthorized: Not authenticated500 Internal Server Error: Failed to create material
Deletes a material.
- URL:
/api/materials/:id - Method:
DELETE - Authentication: Required
- URL Parameters:
id: The ID of the material
- Response:
204 No Content - Error Responses:
400 Bad Request: Invalid material ID401 Unauthorized: Not authenticated404 Not Found: Material not found500 Internal Server Error: Failed to delete material
Returns all colors.
- URL:
/api/colors - Method:
GET - Authentication: Required
- Query Parameters:
export: (optional) If set to 'csv', returns the colors in CSV format
- Response:
200 OK[ { "id": "number", "name": "string", "code": "string" } ] - Error Responses:
401 Unauthorized: Not authenticated500 Internal Server Error: Failed to fetch colors
Creates a new color.
- URL:
/api/colors - Method:
POST - Authentication: Required
- Query Parameters:
import: (optional) If set to 'csv', imports colors from the provided CSV data
- Request Body (for single color):
{ "name": "string", "code": "string" } - Request Body (for CSV import):
{ "csvData": "string" } - Response (for single color):
201 Created{ "id": "number", "name": "string", "code": "string" } - Response (for import):
201 Created{ "created": "number", "duplicates": "number", "errors": "number" } - Error Responses:
400 Bad Request: Validation error401 Unauthorized: Not authenticated500 Internal Server Error: Failed to create color
Deletes a color.
- URL:
/api/colors/:id - Method:
DELETE - Authentication: Required
- URL Parameters:
id: The ID of the color
- Response:
204 No Content - Error Responses:
400 Bad Request: Invalid color ID401 Unauthorized: Not authenticated404 Not Found: Color not found500 Internal Server Error: Failed to delete color
Returns all manufacturers.
- URL:
/api/manufacturers - Method:
GET - Authentication: Required
- Query Parameters:
export: (optional) If set to 'csv', returns the manufacturers in CSV format
- Response:
200 OK[ { "id": "number", "name": "string" } ] - Error Responses:
401 Unauthorized: Not authenticated500 Internal Server Error: Failed to fetch manufacturers
Creates a new manufacturer.
- URL:
/api/manufacturers - Method:
POST - Authentication: Required
- Query Parameters:
import: (optional) If set to 'csv', imports manufacturers from the provided CSV data
- Request Body (for single manufacturer):
{ "name": "string" } - Request Body (for CSV import):
{ "csvData": "string" } - Response (for single manufacturer):
201 Created{ "id": "number", "name": "string" } - Response (for import):
201 Created{ "created": "number", "duplicates": "number", "errors": "number" } - Error Responses:
400 Bad Request: Validation error401 Unauthorized: Not authenticated500 Internal Server Error: Failed to create manufacturer
Deletes a manufacturer.
- URL:
/api/manufacturers/:id - Method:
DELETE - Authentication: Required
- URL Parameters:
id: The ID of the manufacturer
- Response:
204 No Content - Error Responses:
400 Bad Request: Invalid manufacturer ID401 Unauthorized: Not authenticated404 Not Found: Manufacturer not found500 Internal Server Error: Failed to delete manufacturer
Returns all diameters.
- URL:
/api/diameters - Method:
GET - Authentication: Required
- Query Parameters:
export: (optional) If set to 'csv', returns the diameters in CSV format
- Response:
200 OK[ { "id": "number", "value": "string" } ] - Error Responses:
401 Unauthorized: Not authenticated500 Internal Server Error: Failed to fetch diameters
Creates a new diameter.
- URL:
/api/diameters - Method:
POST - Authentication: Required
- Query Parameters:
import: (optional) If set to 'csv', imports diameters from the provided CSV data
- Request Body (for single diameter):
{ "value": "string" } - Request Body (for CSV import):
{ "csvData": "string" } - Response (for single diameter):
201 Created{ "id": "number", "value": "string" } - Response (for import):
201 Created{ "created": "number", "duplicates": "number", "errors": "number" } - Error Responses:
400 Bad Request: Validation error401 Unauthorized: Not authenticated500 Internal Server Error: Failed to create diameter
Deletes a diameter.
- URL:
/api/diameters/:id - Method:
DELETE - Authentication: Required
- URL Parameters:
id: The ID of the diameter
- Response:
204 No Content - Error Responses:
400 Bad Request: Invalid diameter ID401 Unauthorized: Not authenticated404 Not Found: Diameter not found500 Internal Server Error: Failed to delete diameter
Returns all storage locations.
- URL:
/api/storage-locations - Method:
GET - Authentication: Required
- Query Parameters:
export: (optional) If set to 'csv', returns the storage locations in CSV format
- Response:
200 OK[ { "id": "number", "name": "string" } ] - Error Responses:
401 Unauthorized: Not authenticated500 Internal Server Error: Failed to fetch storage locations
Creates a new storage location.
- URL:
/api/storage-locations - Method:
POST - Authentication: Required
- Query Parameters:
import: (optional) If set to 'csv', imports storage locations from the provided CSV data
- Request Body (for single storage location):
{ "name": "string" } - Request Body (for CSV import):
{ "csvData": "string" } - Response (for single storage location):
201 Created{ "id": "number", "name": "string" } - Response (for import):
201 Created{ "created": "number", "duplicates": "number", "errors": "number" } - Error Responses:
400 Bad Request: Validation error401 Unauthorized: Not authenticated500 Internal Server Error: Failed to create storage location
Deletes a storage location.
- URL:
/api/storage-locations/:id - Method:
DELETE - Authentication: Required
- URL Parameters:
id: The ID of the storage location
- Response:
204 No Content - Error Responses:
400 Bad Request: Invalid storage location ID401 Unauthorized: Not authenticated404 Not Found: Storage location not found500 Internal Server Error: Failed to delete storage location
Returns all users (admin only).
- URL:
/api/users - Method:
GET - Authentication: Required (Admin)
- Response:
200 OK[ { "id": "number", "username": "string", "isAdmin": "boolean", "forceChangePassword": "boolean", "language": "string", "createdAt": "string", "lastLogin": "string" } ] - Error Responses:
401 Unauthorized: Not authenticated403 Forbidden: Not an admin500 Internal Server Error: Server error
Creates a new user (admin only).
- URL:
/api/users - Method:
POST - Authentication: Required (Admin)
- Request Body:
{ "username": "string", "password": "string", "isAdmin": "boolean" } - Response:
201 Created{ "id": "number", "username": "string", "isAdmin": "boolean", "forceChangePassword": "boolean", "language": "string", "createdAt": "string" } - Error Responses:
400 Bad Request: Validation error401 Unauthorized: Not authenticated403 Forbidden: Not an admin409 Conflict: Username already exists500 Internal Server Error: Server error
Updates an existing user (admin only).
- URL:
/api/users/:id - Method:
PUT - Authentication: Required (Admin)
- URL Parameters:
id: The ID of the user
- Request Body:
{ "username": "string", "isAdmin": "boolean", "forceChangePassword": "boolean", "language": "string" } - Response:
200 OK{ "id": "number", "username": "string", "isAdmin": "boolean", "forceChangePassword": "boolean", "language": "string", "createdAt": "string", "lastLogin": "string" } - Error Responses:
400 Bad Request: Validation error401 Unauthorized: Not authenticated403 Forbidden: Not an admin404 Not Found: User not found409 Conflict: Username already exists500 Internal Server Error: Server error
Resets a user's password (admin only).
- URL:
/api/users/:id/reset-password - Method:
POST - Authentication: Required (Admin)
- URL Parameters:
id: The ID of the user
- Request Body:
{ "password": "string" } - Response:
200 OK{ "message": "Password reset successfully" } - Error Responses:
400 Bad Request: Validation error401 Unauthorized: Not authenticated403 Forbidden: Not an admin404 Not Found: User not found500 Internal Server Error: Server error
Deletes a user (admin only).
- URL:
/api/users/:id - Method:
DELETE - Authentication: Required (Admin)
- URL Parameters:
id: The ID of the user
- Response:
204 No Content - Error Responses:
400 Bad Request: Invalid user ID401 Unauthorized: Not authenticated403 Forbidden: Not an admin404 Not Found: User not found500 Internal Server Error: Server error
Returns the sharing settings for the authenticated user.
- URL:
/api/user-sharing - Method:
GET - Authentication: Required
- Response:
200 OK[ { "id": "number", "userId": "number", "isPublic": "boolean", "materialId": "number", "createdAt": "string", "updatedAt": "string" } ] - Error Responses:
401 Unauthorized: Not authenticated500 Internal Server Error: Server error
Updates the sharing settings for the authenticated user.
- URL:
/api/sharing - Method:
POST - Authentication: Required
- Request Body:
{ "shareAll": "boolean", "materials": [ { "id": "number", "isPublic": "boolean" } ] } - Response:
200 OK{ "message": "Sharing preferences updated" } - Error Responses:
400 Bad Request: Validation error401 Unauthorized: Not authenticated500 Internal Server Error: Server error
Returns the sharing settings for the authenticated user.
- URL:
/api/sharing - Method:
GET - Authentication: Required
- Response:
200 OK[ { "id": "number", "userId": "number", "isPublic": "boolean", "materialId": "number", "createdAt": "string", "updatedAt": "string" } ] - Error Responses:
401 Unauthorized: Not authenticated500 Internal Server Error: Server error
Returns the public filaments for a specific user.
- URL:
/api/public/filaments/:userId - Method:
GET - Authentication: None
- URL Parameters:
userId: The ID of the user
- Response:
200 OK{ "user": { "id": "number", "username": "string" }, "filaments": [ { "id": "number", "userId": "number", "name": "string", "manufacturer": "string", "material": "string", "colorName": "string", "colorCode": "string", "diameter": "string", "printTemp": "string", "totalWeight": "string", "remainingPercentage": "string", "purchaseDate": "string", "purchasePrice": "string", "status": "string", "spoolType": "string", "dryerCount": "number", "lastDryingDate": "string", "storageLocation": "string", "createdAt": "string", "updatedAt": "string" } ] } - Error Responses:
400 Bad Request: Invalid user ID404 Not Found: User not found or no shared filaments500 Internal Server Error: Server error
Returns statistics for the authenticated user's filaments.
- URL:
/api/statistics - Method:
GET - Authentication: Required
- Response:
200 OK{ "totalSpools": "number", "totalWeight": "string", "remainingWeight": "string", "averageRemaining": "number", "lowStockCount": "number", "materialDistribution": [ { "material": "string", "count": "number", "percentage": "number" } ], "topMaterials": [ { "material": "string", "count": "number" } ], "topColors": [ { "color": "string", "count": "number" } ], "estimatedValue": "number", "totalPurchaseValue": "number", "averageAge": "number", "oldestFilament": { "name": "string", "age": "number" }, "newestFilament": { "name": "string", "age": "number" } } - Error Responses:
401 Unauthorized: Not authenticated500 Internal Server Error: Failed to calculate statistics
Returns the current theme settings.
- URL:
/api/theme - Method:
GET - Authentication: None
- Response:
200 OK{ "variant": "string", "primary": "string", "appearance": "string", "radius": "number" } - Error Responses:
404 Not Found: Theme file not found500 Internal Server Error: Failed to read theme
Updates the theme settings.
- URL:
/api/theme - Method:
POST - Authentication: None
- Request Body:
{ "variant": "string", "primary": "string", "appearance": "string", "radius": "number" } - Response:
200 OK{ "variant": "string", "primary": "string", "appearance": "string", "radius": "number" } - Error Responses:
400 Bad Request: Validation error500 Internal Server Error: Failed to update theme
All API endpoints may return the following error responses:
Returned when the request is malformed or contains invalid data.
{
"message": "string"
}Returned when authentication is required but not provided or is invalid.
{
"message": "Not authenticated"
}Returned when the authenticated user does not have permission to access the resource.
{
"message": "Access denied"
}Returned when the requested resource does not exist.
{
"message": "string"
}Returned when the request conflicts with the current state of the server.
{
"message": "string"
}Returned when an unexpected error occurs on the server.
{
"message": "string"
}Most endpoints require authentication. To authenticate, include the JWT token in a cookie named token. The token is obtained by calling the /api/auth/login endpoint.
Some endpoints are only accessible to users with admin privileges. These endpoints will return a 403 Forbidden response if accessed by a non-admin user.
Many GET endpoints support an export query parameter that allows you to export the data in CSV or JSON format. For example:
GET /api/filaments?export=csv
Many POST endpoints support an import query parameter that allows you to import data from CSV or JSON. For example:
POST /api/filaments?import=csv
When exporting data as CSV, the first line contains the column headers, and each subsequent line contains the data for one record. Fields are separated by commas, and text fields that contain commas are enclosed in double quotes.
When importing data from CSV, the file should follow the same format. The first line may contain column headers, which will be used to map the data to the appropriate fields. If the first line does not contain headers, the data will be mapped based on the order of the columns.
When exporting data as JSON, the response is a JSON array containing objects representing each record.
When importing data from JSON, the request body should contain a jsonData field with a JSON string representing an array of objects.
Currently, the API does not support pagination. All endpoints return all matching records.
Currently, the API does not implement rate limiting.
The API does not currently use versioning in the URL path. Future versions may introduce versioning to maintain backward compatibility.