Get counter
GET
{{server}}/api/v1/counter/deviceThis endpoint returns the counter entity based on the presented Websocket ID in the X-WSID header.
Request
Authorization
| Header | Value |
|---|---|
Authorization | Bearer {{counterToken}} |
Headers
| Key | Value |
|---|---|
Accept | application/json |
X-WSID | {{counterWsID}} |
Code snippets
- cURL
- JavaScript
- Python
curl -X GET '{{server}}/api/v1/counter/device' \
-H 'Accept: application/json' \
-H 'X-WSID: {{counterWsID}}' \
-H 'Authorization: Bearer {{counterToken}}'
const response = await fetch("{{server}}/api/v1/counter/device", {
method: "GET",
headers: {
"Accept": "application/json",
"X-WSID": "{{counterWsID}}",
"Authorization": "Bearer {{counterToken}}"
},
});
const data = await response.json();
console.log(data);
import requests
url = "{{server}}/api/v1/counter/device"
headers = {
"Accept": "application/json",
"X-WSID": "{{counterWsID}}",
"Authorization": "Bearer {{counterToken}}"
}
response = requests.get(url, headers=headers)
print(response.status_code)
print(response.json())
Examples (2)
- Get counter
- Wrong WSID
Example request
GET
{{server}}/api/v1/counter/deviceHeaders (2)
| Key | Value |
|---|---|
Accept | application/json |
X-WSID | {{counterWsID}} |
Example response 200 Ok
Response headers (9)
| Key | Value |
|---|---|
Access-Control-Expose-Headers | * |
Cache-Control | no-store, no-cache, must-revalidate |
Access-Control-Allow-Origin | * |
Access-Control-Allow-Methods | POST, PUT, GET, OPTIONS, DELETE |
Access-Control-Allow-Credentials | true |
Content-Length | 903 |
Access-Control-Max-Age | 86400 |
Access-Control-Allow-Headers | Content-Type, Authorization, X-Requested-With |
Content-Type | application/json;charset=utf-8 |
Body
{
"type": 10,
"key": "00000000-0000-4000-0010-000000000003",
"name": "Web counter 1",
"category": "counter",
"deviceType": 19,
"websocketID": "counter1",
"clientID": "0",
"deviceID": "19",
"branch": "00000000-0000-4000-0003-000000000001",
"special": {
"number": 1,
"animation": true,
"displayGroups": [
{
"key": "18d21b95-7ca5-4e13-b6f9-af1edffb6cbc"
},
{
"key": "18d79492-c467-4347-5334-00cb02a349b3"
},
{
"key": "18dd180c-63a3-408f-e7fb-838eae363006"
},
{
"key": "18e1d208-2d5c-469e-8153-f0c00e11dd16"
},
{
"key": "18f1426f-13a6-499f-415d-c240db586057"
},
{
"key": "18f14500-ef51-4836-139a-37863bd92381"
},
{
"key": "188911b8-5793-412a-b6b8-fd0fd3c27a9b"
}
],
"kind": 1,
"displays": [
"188afdea-5666-4433-c6e7-067d6fef35e3",
"18d5513d-4b96-4640-aa68-529387b4601a"
],
"soundPlayers": [
"188c371c-d0b2-4dd9-7a73-d9a208185986",
"18d79492-3616-43c7-8fe2-1203892967d9"
],
"feedback": null,
"voiceRecorder": null,
"room": "Room 101"
},
"status": 1,
"aspect": null,
"time": 1715935869782
}
Example request
GET
{{server}}/api/v1/counter/deviceHeaders (2)
| Key | Value |
|---|---|
Accept | application/json |
X-WSID | wrongWSID |
Example response 400 Bad Request
Response headers (3)
| Key | Value |
|---|---|
Cache-Control | no-store, no-cache, must-revalidate |
Content-Length | 5180 |
Content-Type | application/json;charset=utf-8 |
Body
{
"name": "errorFactory",
"message": "Device not found (websocket ID: wrongWSID)!",
"nodeID": "norbi-pc3-54396",
"code": 400,
"type": "UNKNOWN_ERROR",
"retryable": false,
"stack": "services.moleculer.error.MoleculerClientError: Device not found (websocket ID: wrongWSID)!\r\n\tat com.qnet7.core.ErrorFactory.clientError(ErrorFactory.java:113)\r\n\tat com.qnet7.core.ErrorFactory.clientError(ErrorFactory.java:63)\r\n\tat com.qnet7.repository.entities.Devices.lambda$1(Devices.java:225)\r\n\tat io.datatree.Promise.lambda$0(Promise.java:403)\r\n\tat java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:836)\r\n\tat java.util.concurrent.CompletableFuture.uniHandleStage(CompletableFuture.java:848)\r\n\tat java.util.concurrent.CompletableFuture.handle(CompletableFuture.java:2168)\r\n\tat io.datatree.Promise.then(Promise.java:398)\r\n\tat com.qnet7.repository.entities.Devices.lambda$0(Devices.java:222)\r\n\tat services.moleculer.service.LocalActionEndpoint.lambda$0(LocalActionEndpoint.java:88)\r\n\tat services.moleculer.cacher.Cacher$2.lambda$1(Cacher.java:167)\r\n\tat io.datatree.Promise.lambda$1(Promise.java:433)\r\n\tat java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:836)\r\n\tat java.util.concurrent.CompletableFuture.uniHandleStage(CompletableFuture.java:848)\r\n\tat java.util.concurrent.CompletableFuture.handle(CompletableFuture.java:2168)\r\n\tat io.datatree.Promise.then(Promise.java:428)\r\n\tat services.moleculer.cacher.Cacher$2.lambda$0(Cacher.java:165)\r\n\tat io.datatree.Promise.<init>(Promise.java:261)\r\n\tat services.moleculer.cacher.Cacher$2.handler(Cacher.java:164)\r\n\tat services.moleculer.metrics.MetricMiddleware$1.lambda$0(MetricMiddleware.java:74)\r\n\tat io.datatree.Promise.<init>(Promise.java:261)\r\n\tat services.moleculer.metrics.MetricMiddleware$1.handler(MetricMiddleware.java:59)\r\n\tat services.moleculer.service.ActionEndpoint.handler(ActionEndpoint.java:85)\r\n\tat services.moleculer.service.DefaultServiceInvoker.call(DefaultServiceInvoker.java:132)\r\n\tat services.moleculer.service.DefaultServiceInvoker.call(DefaultServiceInvoker.java:123)\r\n\tat services.moleculer.context.ContextSource.call(ContextSource.java:478)\r\n\tat services.moleculer.context.ContextSource.call(ContextSource.java:358)\r\n\tat com.qnet7.acl.WSIDResolver$1.service(WSIDResolver.java:83)\r\n\tat services.moleculer.web.router.Mapping.service(Mapping.java:316)\r\n\tat services.moleculer.web.ApiGateway.service(ApiGateway.java:528)\r\n\tat services.moleculer.web.netty.MoleculerHandler.channelRead0(MoleculerHandler.java:147)\r\n\tat io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\r\n\tat io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327)\r\n\tat io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\r\n\tat io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\r\n\tat io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\r\n\tat io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)\r\n\tat io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)\r\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)\r\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)\r\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)\r\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)\r\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)\r\n\tat io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\r\n\tat io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)\r\n\tat java.lang.Thread.run(Thread.java:748)",
"data": {}
}