Naming RESTful API endpoints should follow REST principles: use nouns (not verbs) to represent resources, and use HTTP methods (GET, POST, PUT, DELETE) to indicate actions.
When naming an endpoint related to firmware for a device, the key is to identify the resource clearly. Here are some guidelines and examples:
🔧 Resource Modeling
Ask yourself:
- Is firmware a standalone resource?
- Is it associated with a specific device?
Usually, firmware is a sub-resource of a device.
✅ Recommended Endpoint Naming Examples
1. Firmware by Device
If each device has its own firmware version:
GET /devices/{deviceId}/firmware # Get current firmware info
PUT /devices/{deviceId}/firmware # Update firmware (trigger upload/install)
POST /devices/{deviceId}/firmware # Alternative if PUT is used for upload
GET /devices/{deviceId}/firmware/updates # List available updates
POST /devices/{deviceId}/firmware/update # Trigger firmware update
Note: Avoid verbs in URLs. Use HTTP methods to express action. So /update is discouraged unless it's truly a sub-resource.
Better:
GET /devices/{deviceId}/firmware # Get firmware info
PATCH /devices/{deviceId}/firmware # Modify firmware metadata (optional)
POST /devices/{deviceId}/firmware # Upload new firmware
But this can be confusing because POST is often used to create resources. A better design may treat firmware as a versioned resource.
2. Firmware as a Separate Resource
If firmware is shared across multiple devices or versions matter:
GET /firmwares # List all firmware versions
GET /firmwares/{firmwareId} # Get firmware details
POST /firmwares # Upload/create new firmware
PUT /firmwares/{firmwareId} # Update firmware metadata
DELETE /firmwares/{firmwareId} # Delete firmware (if allowed)
# Associate firmware with device
POST /devices/{deviceId}/firmware # Assign or install firmware on device
GET /devices/{deviceId}/firmware # Get currently installed firmware
You could also model firmware installation as a separate resource:
POST /firmware-installs # Trigger firmware install job
GET /firmware-installs/{installId} # Check install status
3. Firmware Versioning
Include version explicitly if needed:
GET /devices/{deviceId}/firmware/versions
GET /firmwares/{version} # Get specific version
🚫 Names to Avoid
Avoid overly verb-oriented URLs like:
/updateFirmware ❌
/devices/{id}/installFirmware ❌
Instead, use:
/devices/{id}/firmware + POST (to trigger update)
- Or better, separate the installation process into its own resource (e.g.,
/firmware-updates)
✅ Summary Recommendations
| Action | Endpoint Example | Method |
|---|
| Get firmware for a device | /devices/{deviceId}/firmware | GET |
| Upload new firmware | /firmwares or /devices/{deviceId}/firmware | POST |
| Install firmware | /devices/{deviceId}/firmware | PUT/PATCH or POST to /firmware-updates |
| List available updates | /devices/{deviceId}/firmware/updates | GET |
Choose the structure that best reflects your domain model: whether firmware is owned by a device or managed independently.
Would you like help designing the full API schema or OpenAPI spec for this?