This is a lightweight, high-performance API service wrapping the node-device-detector
48
This is a lightweight, high-performance API service wrapping the node-device-detector package, using Node.js and Fastify, encapsulated within a Docker Image.
node:26-alpine Docker container.User-Agent from either the HTTP headers or the ua query parameter.HTTP 200 OK if the User-Agent is empty or missing.Run the newly built Docker image on port 3000:
docker pull madebyai/device-detector:latest
docker run -d -p 3000:3000 --name device-detector madebyai/device-detector:latest
The API service will now be accessible at http://localhost:3000.
The service exposes a single endpoint at GET /detect.
Request:
curl -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" http://localhost:3000/detect
Response:
{
"os": {
"name": "Windows",
"version": "10",
"platform": "x64",
"short_name": "WIN"
},
"client": {
"type": "browser",
"name": "Chrome",
"version": "115.0.0.0",
"engine": "Blink",
"engine_version": "",
"short_name": "CH"
},
"device": {
"type": "desktop",
"brand": "",
"model": ""
}
}
You can pass the User-Agent via the ua query parameter. It must be URL-encoded.
Request:
curl "http://localhost:3000/detect?ua=Mozilla%2F5.0+%28iPhone%3B+CPU+iPhone+OS+16_5+like+Mac+OS+X%29+AppleWebKit%2F605.1.15+%28KHTML%2C+like+Gecko%29+Version%2F16.5+Mobile%2F15E148+Safari%2F604.1"
Response:
{
"os": {
"name": "iOS",
"version": "16.5",
"platform": "",
"short_name": "IOS"
},
"client": {
"type": "browser",
"name": "Mobile Safari",
"version": "16.5",
"engine": "WebKit",
"engine_version": "605.1.15",
"short_name": "MF"
},
"device": {
"type": "smartphone",
"brand": "Apple",
"model": "iPhone"
}
}
If no User-Agent is provided, the API will still return a 200 OK status with default empty values.
Request:
curl http://localhost:3000/detect
Response:
{
"os": {
"name": "",
"version": "",
"platform": "",
"short_name": ""
},
"client": {
"type": "",
"name": "",
"version": "",
"engine": "",
"engine_version": "",
"short_name": ""
},
"device": {
"type": "",
"brand": "",
"model": ""
}
}
Content type
Image
Digest
sha256:e0ddc9b41…
Size
66.7 MB
Last updated
about 1 month ago
docker pull madebyai/device-detector