clockify_detailed_reports_api_docs 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +56 -0
- data/LICENSE.txt +21 -0
- data/README.md +222 -0
- data/docs/Clockify_API_Complete.md +939 -0
- data/docs/Clockify_API_Google_Doc_Internal.md +734 -0
- data/docs/Clockify_API_User_Guide.md +353 -0
- data/lib/clockify_api_docs/documentation.rb +243 -0
- data/lib/clockify_api_docs/version.rb +5 -0
- data/lib/clockify_api_docs.rb +52 -0
- metadata +103 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
# 🚀 Clockify API User Guide - Simple & Easy!
|
|
2
|
+
|
|
3
|
+
> **New to APIs?** No problem! This guide will get you making successful Clockify API calls in minutes.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🎯 What Does This API Do?
|
|
8
|
+
|
|
9
|
+
The Clockify Detailed Reports API lets you:
|
|
10
|
+
- 📊 Get time tracking data from your workspace
|
|
11
|
+
- 💰 See billable hours and earnings
|
|
12
|
+
- 👥 Filter by specific people, projects, or clients
|
|
13
|
+
- 📅 Generate reports for any date range
|
|
14
|
+
- 📤 Export data to Excel, PDF, or CSV
|
|
15
|
+
|
|
16
|
+
Think of it like asking Clockify: *"Show me all the time entries between January and March for Client ABC, but only the billable hours."*
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 🔗 How to Connect
|
|
21
|
+
|
|
22
|
+
**What You Need:**
|
|
23
|
+
1. Your **Workspace ID** (looks like: `60f91b3ffdaf031696ecxxxx`)
|
|
24
|
+
2. Your **API Key** (looks like: `YTVlNzE2YzAtN2Y4Yy00YjQ5LWIzNTUtZGI5MTQ4ZjQyNGFl`)
|
|
25
|
+
|
|
26
|
+
**Where to Send Requests:**
|
|
27
|
+
```
|
|
28
|
+
POST https://reports.api.clockify.me/v1/workspaces/{YOUR_WORKSPACE_ID}/reports/detailed
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Headers to Include:**
|
|
32
|
+
```
|
|
33
|
+
X-Api-Key: YOUR_API_KEY
|
|
34
|
+
Content-Type: application/json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## ⚡ Super Simple Start (Copy & Paste Ready!)
|
|
40
|
+
|
|
41
|
+
Here's the absolute minimum request to get time data:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"dateRangeStart": "2024-01-01T00:00:00.000Z",
|
|
46
|
+
"dateRangeEnd": "2024-01-31T23:59:59.999Z",
|
|
47
|
+
"detailedFilter": {
|
|
48
|
+
"page": 1,
|
|
49
|
+
"pageSize": 50
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**What this does:** Gets the first 50 time entries from January 2024.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 🎨 Customize Your Request (Pick What You Want!)
|
|
59
|
+
|
|
60
|
+
### 📅 **Change the Date Range**
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"dateRangeStart": "2024-06-01T00:00:00.000Z", // June 1st
|
|
64
|
+
"dateRangeEnd": "2024-06-30T23:59:59.999Z", // June 30th
|
|
65
|
+
"detailedFilter": {"page": 1, "pageSize": 50}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 👤 **Get Data for Specific People**
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"dateRangeStart": "2024-01-01T00:00:00.000Z",
|
|
73
|
+
"dateRangeEnd": "2024-01-31T23:59:59.999Z",
|
|
74
|
+
"users": {
|
|
75
|
+
"contains": "CONTAINS",
|
|
76
|
+
"ids": ["user_id_here"],
|
|
77
|
+
"status": "ACTIVE"
|
|
78
|
+
},
|
|
79
|
+
"detailedFilter": {"page": 1, "pageSize": 50}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 🏢 **Get Data for Specific Clients**
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"dateRangeStart": "2024-01-01T00:00:00.000Z",
|
|
87
|
+
"dateRangeEnd": "2024-01-31T23:59:59.999Z",
|
|
88
|
+
"clients": {
|
|
89
|
+
"contains": "CONTAINS",
|
|
90
|
+
"ids": ["client_id_here"],
|
|
91
|
+
"status": "ACTIVE"
|
|
92
|
+
},
|
|
93
|
+
"detailedFilter": {"page": 1, "pageSize": 50}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 💰 **Include Financial Data**
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"dateRangeStart": "2024-01-01T00:00:00.000Z",
|
|
101
|
+
"dateRangeEnd": "2024-01-31T23:59:59.999Z",
|
|
102
|
+
"amountShown": "EARNED", // Shows how much money was earned
|
|
103
|
+
"billable": true, // Only billable time
|
|
104
|
+
"detailedFilter": {"page": 1, "pageSize": 50}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 📤 **Get Data as Excel File**
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"dateRangeStart": "2024-01-01T00:00:00.000Z",
|
|
112
|
+
"dateRangeEnd": "2024-01-31T23:59:59.999Z",
|
|
113
|
+
"exportType": "XLSX", // Excel format
|
|
114
|
+
"detailedFilter": {"page": 1, "pageSize": 50}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 🔧 Useful Options You Can Add
|
|
121
|
+
|
|
122
|
+
### **Money Options** (`amountShown`)
|
|
123
|
+
- `"EARNED"` - Revenue from billable time
|
|
124
|
+
- `"COST"` - How much you paid employees
|
|
125
|
+
- `"PROFIT"` - Earned minus cost
|
|
126
|
+
|
|
127
|
+
### **File Format Options** (`exportType`)
|
|
128
|
+
- `"JSON"` - For programming (default)
|
|
129
|
+
- `"CSV"` - For Excel/Google Sheets
|
|
130
|
+
- `"XLSX"` - Excel file
|
|
131
|
+
- `"PDF"` - Formatted report
|
|
132
|
+
|
|
133
|
+
### **Filter Options**
|
|
134
|
+
- `"billable": true` - Only billable time
|
|
135
|
+
- `"billable": false` - Only non-billable time
|
|
136
|
+
- `"description": "meeting"` - Find entries containing "meeting"
|
|
137
|
+
- `"archived": true` - Include archived projects/clients
|
|
138
|
+
|
|
139
|
+
### **Sort Options**
|
|
140
|
+
- `"sortColumn": "DATE"` - Sort by date (goes in detailedFilter)
|
|
141
|
+
- `"sortColumn": "USER"` - Sort by person
|
|
142
|
+
- `"sortColumn": "DURATION"` - Sort by time length
|
|
143
|
+
- `"sortOrder": "DESCENDING"` - Newest first (separate parameter)
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 📋 What You Get Back
|
|
148
|
+
|
|
149
|
+
The API returns data like this:
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"timeEntries": [
|
|
154
|
+
{
|
|
155
|
+
"id": "entry_123",
|
|
156
|
+
"userName": "John Smith",
|
|
157
|
+
"userEmail": "john@company.com",
|
|
158
|
+
"projectName": "Website Design",
|
|
159
|
+
"clientName": "ABC Company",
|
|
160
|
+
"timeInterval": {
|
|
161
|
+
"start": "2024-01-15T09:00:00Z",
|
|
162
|
+
"end": "2024-01-15T17:00:00Z",
|
|
163
|
+
"duration": 28800 // Seconds (28800 = 8 hours)
|
|
164
|
+
},
|
|
165
|
+
"description": "Design homepage mockups",
|
|
166
|
+
"billable": true
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
"totals": [
|
|
170
|
+
{
|
|
171
|
+
"totalTime": 86400, // Total seconds for ALL data
|
|
172
|
+
"totalBillableTime": 28800, // Billable seconds
|
|
173
|
+
"entriesCount": 10 // Total number of entries
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Important:** `duration` is in seconds. Divide by 3600 to get hours.
|
|
180
|
+
- 3600 seconds = 1 hour
|
|
181
|
+
- 28800 seconds = 8 hours
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 🚨 Common Problems & Solutions
|
|
186
|
+
|
|
187
|
+
### **❌ "Field dateRangeStart is required"**
|
|
188
|
+
**Problem:** Missing required dates
|
|
189
|
+
**Solution:** Always include both dates:
|
|
190
|
+
```json
|
|
191
|
+
{
|
|
192
|
+
"dateRangeStart": "2024-01-01T00:00:00.000Z",
|
|
193
|
+
"dateRangeEnd": "2024-01-31T23:59:59.999Z",
|
|
194
|
+
"detailedFilter": {"page": 1, "pageSize": 50}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### **❌ "Invalid date format"**
|
|
199
|
+
**Problem:** Wrong date format
|
|
200
|
+
**Solution:** Use exact format `YYYY-MM-DDTHH:MM:SS.sssZ`:
|
|
201
|
+
```json
|
|
202
|
+
"dateRangeStart": "2024-01-01T00:00:00.000Z" // ✅ Correct
|
|
203
|
+
"dateRangeStart": "2024-01-01" // ❌ Wrong
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### **❌ "Unauthorized"**
|
|
207
|
+
**Problem:** Wrong API key or workspace ID
|
|
208
|
+
**Solution:** Double-check your credentials in Clockify settings
|
|
209
|
+
|
|
210
|
+
### **❌ "Maximum page size is 1,000"**
|
|
211
|
+
**Problem:** `pageSize` too large
|
|
212
|
+
**Solution:** Use `pageSize` between 1 and 1000:
|
|
213
|
+
```json
|
|
214
|
+
"detailedFilter": {"page": 1, "pageSize": 100} // ✅ Good
|
|
215
|
+
"detailedFilter": {"page": 1, "pageSize": 2000} // ❌ Too big
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### **❌ Getting No Results**
|
|
219
|
+
**Problem:** Filters are too restrictive
|
|
220
|
+
**Solution:** Start simple, then add filters:
|
|
221
|
+
1. Try without any filters first
|
|
222
|
+
2. Add one filter at a time
|
|
223
|
+
3. Check if data exists in your date range
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## 💡 Pro Tips
|
|
228
|
+
|
|
229
|
+
### **🔄 Get More Results (Pagination)**
|
|
230
|
+
If you have lots of data, get it in chunks:
|
|
231
|
+
```json
|
|
232
|
+
// Get first 100 entries
|
|
233
|
+
{"detailedFilter": {"page": 1, "pageSize": 100}}
|
|
234
|
+
|
|
235
|
+
// Get next 100 entries
|
|
236
|
+
{"detailedFilter": {"page": 2, "pageSize": 100}}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### **⚡ Speed Up Requests**
|
|
240
|
+
- Use smaller `pageSize` (50-200) for faster responses
|
|
241
|
+
- Use specific date ranges instead of very large ones
|
|
242
|
+
- Filter early (add `billable`, `clients`, etc. to reduce data)
|
|
243
|
+
|
|
244
|
+
### **💰 Invoice Workflow**
|
|
245
|
+
To generate invoices:
|
|
246
|
+
```json
|
|
247
|
+
{
|
|
248
|
+
"dateRangeStart": "2024-01-01T00:00:00.000Z",
|
|
249
|
+
"dateRangeEnd": "2024-01-31T23:59:59.999Z",
|
|
250
|
+
"clients": {"contains": "CONTAINS", "ids": ["client_id"], "status": "ACTIVE"},
|
|
251
|
+
"billable": true,
|
|
252
|
+
"invoicingState": "UNINVOICED", // Only un-invoiced time
|
|
253
|
+
"amountShown": "EARNED",
|
|
254
|
+
"detailedFilter": {"page": 1, "pageSize": 1000}
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### **📊 Team Reports**
|
|
259
|
+
To see team productivity:
|
|
260
|
+
```json
|
|
261
|
+
{
|
|
262
|
+
"dateRangeStart": "2024-01-01T00:00:00.000Z",
|
|
263
|
+
"dateRangeEnd": "2024-01-31T23:59:59.999Z",
|
|
264
|
+
"userGroups": {"contains": "CONTAINS", "ids": ["team_id"], "status": "ACTIVE"},
|
|
265
|
+
"sortOrder": "ASCENDING",
|
|
266
|
+
"detailedFilter": {"page": 1, "pageSize": 200, "sortColumn": "USER"}
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### **📈 Summary Reports (Advanced)**
|
|
271
|
+
To get grouped summary data:
|
|
272
|
+
```json
|
|
273
|
+
{
|
|
274
|
+
"dateRangeStart": "2024-01-01T00:00:00.000Z",
|
|
275
|
+
"dateRangeEnd": "2024-01-31T23:59:59.999Z",
|
|
276
|
+
"summaryFilter": {
|
|
277
|
+
"groups": ["PROJECT", "CLIENT"], // Group by projects and clients
|
|
278
|
+
"sortColumn": "DURATION"
|
|
279
|
+
},
|
|
280
|
+
"detailedFilter": {"page": 1, "pageSize": 100}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Summary Group Options**: `PROJECT`, `CLIENT`, `USER`, `TASK`, `TAG`, `DATE`, `WEEK`, `MONTH`, `USER_GROUP`, `TIMEENTRY`
|
|
285
|
+
**⚠️ Important**: Must include 1-3 group types, can't be empty!
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## 🎯 Real-World Examples
|
|
290
|
+
|
|
291
|
+
### **Example 1: Monthly Client Report**
|
|
292
|
+
*"Show me all billable work for Client ABC in March 2024"*
|
|
293
|
+
```json
|
|
294
|
+
{
|
|
295
|
+
"dateRangeStart": "2024-03-01T00:00:00.000Z",
|
|
296
|
+
"dateRangeEnd": "2024-03-31T23:59:59.999Z",
|
|
297
|
+
"clients": {"contains": "CONTAINS", "ids": ["abc_client_id"], "status": "ACTIVE"},
|
|
298
|
+
"billable": true,
|
|
299
|
+
"amountShown": "EARNED",
|
|
300
|
+
"sortOrder": "ASCENDING",
|
|
301
|
+
"detailedFilter": {"page": 1, "pageSize": 500, "sortColumn": "DATE"}
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### **Example 2: Find Missing Descriptions**
|
|
306
|
+
*"Show me time entries that are missing descriptions for quality check"*
|
|
307
|
+
```json
|
|
308
|
+
{
|
|
309
|
+
"dateRangeStart": "2024-01-01T00:00:00.000Z",
|
|
310
|
+
"dateRangeEnd": "2024-01-31T23:59:59.999Z",
|
|
311
|
+
"withoutDescription": true,
|
|
312
|
+
"detailedFilter": {"page": 1, "pageSize": 200}
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### **Example 3: Export to Excel**
|
|
317
|
+
*"Get all January data as Excel file for accounting"*
|
|
318
|
+
```json
|
|
319
|
+
{
|
|
320
|
+
"dateRangeStart": "2024-01-01T00:00:00.000Z",
|
|
321
|
+
"dateRangeEnd": "2024-01-31T23:59:59.999Z",
|
|
322
|
+
"exportType": "XLSX",
|
|
323
|
+
"amountShown": "EARNED",
|
|
324
|
+
"detailedFilter": {"page": 1, "pageSize": 1000}
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## 🆘 Still Need Help?
|
|
331
|
+
|
|
332
|
+
### **Test Your Request**
|
|
333
|
+
1. Start with the simple example at the top
|
|
334
|
+
2. Add one parameter at a time
|
|
335
|
+
3. Check the response after each change
|
|
336
|
+
4. If you get errors, remove the last thing you added
|
|
337
|
+
|
|
338
|
+
### **Common Beginner Mistakes**
|
|
339
|
+
- ❌ Forgetting the `detailedFilter` object
|
|
340
|
+
- ❌ Using wrong date format (must end with `.000Z`)
|
|
341
|
+
- ❌ Setting `pageSize` too high (max is 1000)
|
|
342
|
+
- ❌ Using empty strings (`""`) in parameters
|
|
343
|
+
|
|
344
|
+
### **Quick Debugging**
|
|
345
|
+
If something's not working:
|
|
346
|
+
1. Check your API key and workspace ID
|
|
347
|
+
2. Verify date format is exactly `YYYY-MM-DDTHH:MM:SS.000Z`
|
|
348
|
+
3. Try the basic example first
|
|
349
|
+
4. Add parameters one by one
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
**🎉 You're Ready!** Start with the simple example and build up from there. The API is powerful but friendly once you get the basics down!
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
|
|
5
|
+
module ClockifyApiDocs
|
|
6
|
+
class Documentation
|
|
7
|
+
def initialize
|
|
8
|
+
@docs_path = File.join(__dir__, '..', '..', 'docs')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Get user-friendly guide content
|
|
12
|
+
def user_guide
|
|
13
|
+
read_doc_file('Clockify_API_User_Guide.md')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Get complete technical reference
|
|
17
|
+
def complete_reference
|
|
18
|
+
read_doc_file('Clockify_API_Complete.md')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Get internal documentation
|
|
22
|
+
def internal_documentation
|
|
23
|
+
read_doc_file('Clockify_API_Google_Doc_Internal.md')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Save all documentation to a directory
|
|
27
|
+
def save_all_to_directory(output_path)
|
|
28
|
+
FileUtils.mkdir_p(output_path)
|
|
29
|
+
|
|
30
|
+
files = {
|
|
31
|
+
'Clockify_API_User_Guide.md' => user_guide,
|
|
32
|
+
'Clockify_API_Complete.md' => complete_reference,
|
|
33
|
+
'Clockify_API_Google_Doc_Internal.md' => internal_documentation
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
files.each do |filename, content|
|
|
37
|
+
File.write(File.join(output_path, filename), content)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
puts "📚 All documentation saved to: #{output_path}"
|
|
41
|
+
files.keys
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Search documentation for specific terms
|
|
45
|
+
def search(query)
|
|
46
|
+
results = []
|
|
47
|
+
|
|
48
|
+
[
|
|
49
|
+
{ name: 'User Guide', content: user_guide },
|
|
50
|
+
{ name: 'Complete Reference', content: complete_reference },
|
|
51
|
+
{ name: 'Internal Documentation', content: internal_documentation }
|
|
52
|
+
].each do |doc|
|
|
53
|
+
lines = doc[:content].split("\n")
|
|
54
|
+
lines.each_with_index do |line, index|
|
|
55
|
+
if line.downcase.include?(query.downcase)
|
|
56
|
+
results << {
|
|
57
|
+
document: doc[:name],
|
|
58
|
+
line_number: index + 1,
|
|
59
|
+
content: line.strip,
|
|
60
|
+
context: get_context(lines, index, 2)
|
|
61
|
+
}
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
results
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# List all documented errors
|
|
70
|
+
def list_errors
|
|
71
|
+
content = complete_reference
|
|
72
|
+
errors = []
|
|
73
|
+
|
|
74
|
+
# Extract errors from the complete reference
|
|
75
|
+
in_error_section = false
|
|
76
|
+
content.split("\n").each do |line|
|
|
77
|
+
if line.include?("Complete Error Reference")
|
|
78
|
+
in_error_section = true
|
|
79
|
+
next
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
if in_error_section && line.match(/^\s*-\s+`(\d+\/\d+)`:\s+(.+)/)
|
|
83
|
+
code = $1
|
|
84
|
+
description = $2
|
|
85
|
+
errors << { code: code, description: description }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
break if in_error_section && line.include?("## 🎯")
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
errors
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Get API endpoint information
|
|
95
|
+
def endpoint_info
|
|
96
|
+
{
|
|
97
|
+
url: "https://reports.api.clockify.me/v1/workspaces/{workspaceId}/reports/detailed",
|
|
98
|
+
method: "POST",
|
|
99
|
+
authentication: "X-Api-Key header required",
|
|
100
|
+
content_type: "application/json"
|
|
101
|
+
}
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Get quick start example
|
|
105
|
+
def quick_start_example
|
|
106
|
+
{
|
|
107
|
+
minimal: {
|
|
108
|
+
"dateRangeStart" => "2024-01-01T00:00:00.000Z",
|
|
109
|
+
"dateRangeEnd" => "2024-12-31T23:59:59.999Z",
|
|
110
|
+
"detailedFilter" => {
|
|
111
|
+
"page" => 1,
|
|
112
|
+
"pageSize" => 100
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
private
|
|
119
|
+
|
|
120
|
+
def read_doc_file(filename)
|
|
121
|
+
file_path = File.join(@docs_path, filename)
|
|
122
|
+
if File.exist?(file_path)
|
|
123
|
+
File.read(file_path)
|
|
124
|
+
else
|
|
125
|
+
# Return embedded content if file not found
|
|
126
|
+
case filename
|
|
127
|
+
when 'Clockify_API_User_Guide.md'
|
|
128
|
+
USER_GUIDE_CONTENT
|
|
129
|
+
when 'Clockify_API_Complete.md'
|
|
130
|
+
COMPLETE_REFERENCE_CONTENT
|
|
131
|
+
when 'Clockify_API_Google_Doc_Internal.md'
|
|
132
|
+
INTERNAL_DOCUMENTATION_CONTENT
|
|
133
|
+
else
|
|
134
|
+
"Documentation file not found: #{filename}"
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def get_context(lines, index, context_size)
|
|
140
|
+
start_idx = [0, index - context_size].max
|
|
141
|
+
end_idx = [lines.length - 1, index + context_size].min
|
|
142
|
+
|
|
143
|
+
lines[start_idx..end_idx].map.with_index(start_idx + 1) do |line, line_num|
|
|
144
|
+
prefix = line_num == index + 1 ? ">>> " : " "
|
|
145
|
+
"#{prefix}#{line_num}: #{line}"
|
|
146
|
+
end.join("\n")
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Embedded documentation content (fallback if files not found)
|
|
150
|
+
USER_GUIDE_CONTENT = <<~USER_GUIDE
|
|
151
|
+
# 🚀 Clockify API User Guide - Simple & Easy!
|
|
152
|
+
|
|
153
|
+
> **New to APIs?** No problem! This guide will get you making successful Clockify API calls in minutes.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 🎯 What Does This API Do?
|
|
158
|
+
|
|
159
|
+
The Clockify Detailed Reports API lets you:
|
|
160
|
+
- 📊 Get time tracking data from your workspace
|
|
161
|
+
- 💰 See billable hours and earnings
|
|
162
|
+
- 👥 Filter by specific people, projects, or clients
|
|
163
|
+
- 📅 Generate reports for any date range
|
|
164
|
+
- 📤 Export data to Excel, PDF, or CSV
|
|
165
|
+
|
|
166
|
+
Think of it like asking Clockify: *"Show me all the time entries between January and March for Client ABC, but only the billable hours."*
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## ⚡ Super Simple Start (Copy & Paste Ready!)
|
|
171
|
+
|
|
172
|
+
Here's the absolute minimum request to get time data:
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"dateRangeStart": "2024-01-01T00:00:00.000Z",
|
|
177
|
+
"dateRangeEnd": "2024-01-31T23:59:59.999Z",
|
|
178
|
+
"detailedFilter": {
|
|
179
|
+
"page": 1,
|
|
180
|
+
"pageSize": 50
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**🎉 You're Ready!** Start with the simple example and build up from there!
|
|
186
|
+
USER_GUIDE
|
|
187
|
+
|
|
188
|
+
COMPLETE_REFERENCE_CONTENT = <<~COMPLETE_REF
|
|
189
|
+
# 📚 Clockify Detailed Reports API - Complete Reference
|
|
190
|
+
|
|
191
|
+
## 🔗 **Endpoint**
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
POST https://reports.api.clockify.me/v1/workspaces/{workspaceId}/reports/detailed
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Authentication**: `X-Api-Key: YOUR_API_KEY`
|
|
198
|
+
|
|
199
|
+
## ⚡ **Quick Start (Minimal Required Call)**
|
|
200
|
+
|
|
201
|
+
```json
|
|
202
|
+
{
|
|
203
|
+
"dateRangeStart": "2024-01-01T00:00:00.000Z",
|
|
204
|
+
"dateRangeEnd": "2024-12-31T23:59:59.999Z",
|
|
205
|
+
"detailedFilter": {
|
|
206
|
+
"page": 1,
|
|
207
|
+
"pageSize": 100
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**📊 Total Documented Errors**: 40+
|
|
213
|
+
**🔬 Based on**: Comprehensive API testing
|
|
214
|
+
**⚠️ More Accurate Than**: Official Clockify API documentation
|
|
215
|
+
COMPLETE_REF
|
|
216
|
+
|
|
217
|
+
INTERNAL_DOCUMENTATION_CONTENT = <<~INTERNAL_DOC
|
|
218
|
+
# Clockify Detailed Reports API - Internal Documentation
|
|
219
|
+
|
|
220
|
+
## Executive Summary
|
|
221
|
+
|
|
222
|
+
This documentation provides comprehensive coverage of the Clockify Detailed Reports API based on extensive testing and validation.
|
|
223
|
+
|
|
224
|
+
## Key Findings
|
|
225
|
+
|
|
226
|
+
- 40+ documented API errors
|
|
227
|
+
- AttendanceFilter has different pagination limits (201 vs 1000)
|
|
228
|
+
- Official Clockify documentation contains errors
|
|
229
|
+
- Server crashes from empty strings in certain fields
|
|
230
|
+
|
|
231
|
+
## Implementation Guide
|
|
232
|
+
|
|
233
|
+
### Authentication
|
|
234
|
+
- API Key: Required in X-Api-Key header
|
|
235
|
+
- Workspace ID: Required in URL path
|
|
236
|
+
|
|
237
|
+
### Production Considerations
|
|
238
|
+
- Implement proper error handling for 40+ documented errors
|
|
239
|
+
- Use pagination for large datasets
|
|
240
|
+
- Monitor rate limits and implement retries
|
|
241
|
+
INTERNAL_DOC
|
|
242
|
+
end
|
|
243
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "clockify_api_docs/version"
|
|
4
|
+
require_relative "clockify_api_docs/documentation"
|
|
5
|
+
|
|
6
|
+
module ClockifyApiDocs
|
|
7
|
+
class Error < StandardError; end
|
|
8
|
+
|
|
9
|
+
# Main entry point for accessing Clockify Detailed Reports API documentation
|
|
10
|
+
def self.documentation
|
|
11
|
+
Documentation.new
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Quick access to user guide
|
|
15
|
+
def self.user_guide
|
|
16
|
+
documentation.user_guide
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Quick access to complete reference
|
|
20
|
+
def self.complete_reference
|
|
21
|
+
documentation.complete_reference
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Quick access to internal documentation
|
|
25
|
+
def self.internal_documentation
|
|
26
|
+
documentation.internal_documentation
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Print available documentation
|
|
30
|
+
def self.help
|
|
31
|
+
puts <<~HELP
|
|
32
|
+
🚀 Clockify Detailed Reports API Documentation Gem
|
|
33
|
+
|
|
34
|
+
📊 SPECIFIC TO: POST /reports/detailed endpoint ONLY
|
|
35
|
+
⚠️ NOT general Clockify API docs - just the detailed reports endpoint
|
|
36
|
+
|
|
37
|
+
Available documentation:
|
|
38
|
+
|
|
39
|
+
• ClockifyApiDocs.user_guide - Beginner-friendly guide
|
|
40
|
+
• ClockifyApiDocs.complete_reference - Complete technical reference
|
|
41
|
+
• ClockifyApiDocs.internal_documentation - Internal/team documentation
|
|
42
|
+
|
|
43
|
+
Methods:
|
|
44
|
+
|
|
45
|
+
• ClockifyApiDocs.documentation.save_all_to_directory(path) - Save all docs to folder
|
|
46
|
+
• ClockifyApiDocs.documentation.list_errors - Show all documented API errors
|
|
47
|
+
• ClockifyApiDocs.documentation.search(query) - Search documentation
|
|
48
|
+
|
|
49
|
+
📚 More accurate than official Clockify documentation - based on real API testing!
|
|
50
|
+
HELP
|
|
51
|
+
end
|
|
52
|
+
end
|