|
1 | | -# Counters API |
2 | | - |
3 | | -## `GET /counters` |
4 | | - |
5 | | -#### Description: |
6 | | - |
7 | | -Fetches all available counters. |
8 | | - |
9 | | -#### Example Request: |
10 | | - |
11 | | -``` |
12 | | -GET /counters |
13 | | -``` |
| 1 | +export const metadata = { |
| 2 | + title: 'Counters', |
| 3 | + description: 'Documentation for counter API endpoints.', |
| 4 | +} |
14 | 5 |
|
15 | | -#### Example Response: |
| 6 | +# Counters |
16 | 7 |
|
17 | | -```json |
18 | | -[ |
19 | | - { |
20 | | - "id": "counter1", |
21 | | - "name": "Counter 1", |
22 | | - "value": 10 |
23 | | - }, |
24 | | - { |
25 | | - "id": "counter2", |
26 | | - "name": "Counter 2", |
27 | | - "value": 15 |
28 | | - } |
29 | | -] |
30 | | -``` |
| 8 | +The Counters API allows you to manage and retrieve counter values. |
31 | 9 |
|
32 | 10 | --- |
33 | 11 |
|
34 | | -## `GET /counters/:counterId` |
35 | | - |
36 | | -#### Description: |
37 | | - |
38 | | -Fetches a specific counter by its `counterId`. |
39 | | - |
40 | | -#### Request Parameters: |
41 | | - |
42 | | -- `counterId`: The unique identifier of the counter. |
43 | | - |
44 | | -#### Example Request: |
45 | | - |
46 | | -``` |
47 | | -GET /counters/counter1 |
48 | | -``` |
49 | | - |
50 | | -#### Example Response: |
51 | | - |
52 | | -```json |
53 | | -{ |
54 | | - "id": "counter1", |
55 | | - "name": "Counter 1", |
56 | | - "value": 10 |
57 | | -} |
58 | | -``` |
| 12 | +## List all counters {{ tag: 'GET', label: '/counters' }} |
| 13 | + |
| 14 | +<Row> |
| 15 | + <Col> |
| 16 | + Retrieves a list of all counters |
| 17 | + </Col> |
| 18 | + |
| 19 | + <Col sticky> |
| 20 | + <CodeGroup title="Request" tag="GET" label="/counters"> |
| 21 | + ```bash {{ title: 'cURL' }} |
| 22 | + curl http://localhost:7472/api/v1/counters |
| 23 | + ``` |
| 24 | + </CodeGroup> |
| 25 | + |
| 26 | + ```json {{ title: 'Response' }} |
| 27 | + [ |
| 28 | + { |
| 29 | + "id": "counter1", |
| 30 | + "name": "Counter 1", |
| 31 | + "value": 10 |
| 32 | + }, |
| 33 | + { |
| 34 | + "id": "counter2", |
| 35 | + "name": "Counter 2", |
| 36 | + "value": 15 |
| 37 | + } |
| 38 | + ] |
| 39 | + ``` |
| 40 | + </Col> |
| 41 | +</Row> |
59 | 42 |
|
60 | 43 | --- |
61 | 44 |
|
62 | | -## `POST /counters/:counterId` |
63 | | - |
64 | | -#### Description: |
65 | | - |
66 | | -Updates the value of an existing counter. Optionally, you can override the current value. |
67 | | - |
68 | | -#### Request Parameters: |
69 | | - |
70 | | -- `counterId`: The unique identifier of the counter to be updated. |
71 | | - |
72 | | -#### Request Body: |
| 45 | +## Retrieve a counter {{ tag: 'GET', label: '/counters/:counterId' }} |
| 46 | + |
| 47 | +<Row> |
| 48 | + <Col> |
| 49 | + Fetches a specific counter by its `counterId`. |
| 50 | + |
| 51 | + ### URL Parameters |
| 52 | + <Properties> |
| 53 | + <Property name="counterId" type="string" required> |
| 54 | + The unique identifier of the counter |
| 55 | + </Property> |
| 56 | + </Properties> |
| 57 | + </Col> |
| 58 | + |
| 59 | + <Col sticky> |
| 60 | + <CodeGroup title="Request" tag="GET" label="/counters/counter1"> |
| 61 | + ```bash {{ title: 'cURL' }} |
| 62 | + curl http://localhost:7472/api/v1/counters/counter1 |
| 63 | + ``` |
| 64 | + </CodeGroup> |
| 65 | + |
| 66 | + ```json {{ title: 'Response' }} |
| 67 | + { |
| 68 | + "id": "counter1", |
| 69 | + "name": "Counter 1", |
| 70 | + "value": 10 |
| 71 | + } |
| 72 | + ``` |
| 73 | + </Col> |
| 74 | +</Row> |
73 | 75 |
|
74 | | -- `value`: The new value to set for the counter (required). |
75 | | -- `override`: A boolean indicating whether to override the counter's current value (optional, defaults to `false`). |
76 | | - |
77 | | -#### Example Request: |
78 | | - |
79 | | -```json |
80 | | -{ |
81 | | - "value": 20, |
82 | | - "override": true |
83 | | -} |
84 | | -``` |
85 | | - |
86 | | -#### Example Response: |
| 76 | +--- |
87 | 77 |
|
88 | | -```json |
89 | | -{ |
90 | | - "oldValue": 10, |
91 | | - "newValue": 20 |
92 | | -} |
93 | | -``` |
| 78 | +## Update a counter {{ tag: 'POST', label: '/counters/:counterId' }} |
| 79 | + |
| 80 | +<Row> |
| 81 | + <Col> |
| 82 | + Updates the value of an existing counter. Optionally, you can override the current value. |
| 83 | + |
| 84 | + ### Request Parameters |
| 85 | + <Properties> |
| 86 | + <Property name="counterId" type="string" required> |
| 87 | + The unique identifier of the counter to be updated |
| 88 | + </Property> |
| 89 | + </Properties> |
| 90 | + |
| 91 | + ### Request Body |
| 92 | + <Properties> |
| 93 | + <Property name="value" type="number" required> |
| 94 | + The new value to set for the counter |
| 95 | + </Property> |
| 96 | + <Property name="override" type="boolean"> |
| 97 | + A boolean indicating whether to override the counter's current value. |
| 98 | + If false, the new value will be added to the current value (optional, defaults to `false`) |
| 99 | + </Property> |
| 100 | + </Properties> |
| 101 | + </Col> |
| 102 | + |
| 103 | + <Col sticky> |
| 104 | + <CodeGroup title="Request" tag="POST" label="/counters/counter1"> |
| 105 | + ```bash {{ title: 'cURL' }} |
| 106 | + curl -X POST http://localhost:7472/api/v1/counters/counter1 \ |
| 107 | + -H "Content-Type: application/json" \ |
| 108 | + -d '{"value": 20, "override": true}' |
| 109 | + ``` |
| 110 | + </CodeGroup> |
| 111 | + |
| 112 | + ```json {{ title: 'Response' }} |
| 113 | + { |
| 114 | + "oldValue": 10, |
| 115 | + "newValue": 20 |
| 116 | + } |
| 117 | + ``` |
| 118 | + </Col> |
| 119 | +</Row> |
0 commit comments