1
- # tech-report-apis
1
+ # Technology Reports API (Node.js)
2
2
3
- APIs for the HTTP Archive Technology Report
3
+ This is a unified Google Cloud Run function that provides technology metrics and information via various endpoints.
4
4
5
- ## API
5
+ ## Setup
6
6
7
- ## Endpoints
7
+ ### Prerequisites
8
8
9
- ### ` GET /adoption `
9
+ - Node.js 18+
10
+ - npm
11
+ - Google Cloud account with necessary permissions
12
+ - Set environment variables:
13
+
14
+ ``` bash
15
+ export PROJECT=httparchive
16
+ export DATABASE=tech-report-apis-prod
17
+ ```
18
+
19
+ # ## Local Development
20
+
21
+ ` ` ` bash
22
+ npm install
23
+ npm start:functions
24
+ ` ` `
25
+
26
+ The API will be available at < http://localhost:8080>
27
+
28
+ # ## Google Cloud Functions Mode
29
+
30
+ ` ` ` bash
31
+ npm install
32
+ npm run start:functions
33
+ ` ` `
34
+
35
+ The function will run on ` http://localhost:8080`
36
+
37
+ # # Deployment
38
+
39
+ # ## Deploy to Google Cloud Run Function
40
+
41
+ ` ` ` bash
42
+ # Deploy to Google Cloud Functions
43
+ gcloud functions deploy tech-report-api \
44
+ --runtime nodejs22 \
45
+ --trigger-http \
46
+ --allow-unauthenticated \
47
+ --entry-point api \
48
+ --source .
49
+ ` ` `
50
+
51
+ # # API Endpoints
52
+
53
+ # # Features
54
+
55
+ - ** ETag Support** : All endpoints include ETag headers for efficient caching
56
+ - ** CORS Enabled** : Cross-origin requests are supported
57
+ - ** Cache Headers** : 6-hour cache control for static data
58
+ - ** Health Check** : GET ` /` returns health status
59
+ - ** RESTful API** : All endpoints follow REST conventions
60
+
61
+ # ## `GET /`
62
+
63
+ Health check
64
+
65
+ # ## `GET /technologies`
66
+
67
+ Lists available technologies with optional filtering.
10
68
11
69
# ### Parameters
12
70
13
- The following parameters can be used to filter the data:
71
+ - ` technology` (optional): Filter by technology name(s) - comma-separated list
72
+ - ` category` (optional): Filter by category - comma-separated list
73
+ - ` onlyname` (optional): If present, returns only technology names
74
+
75
+ # ### Example Request & Response
76
+
77
+ ` ` ` bash
78
+ curl --request GET \
79
+ --url ' https://{{HOST}}/v1/technologies?category=Live%20chat%2C%20blog&technology=Smartsupp'
80
+ ` ` `
14
81
15
- - ` geo ` (` required ` ): A string representing the geographic location.
16
- - ` technology ` (` required ` ): A comma-separated string representing the technology name(s).
17
- - ` rank ` (` required ` ): An string representing the rank.
18
- - ` start ` (optional): A string representing the start date in the format ` YYYY-MM-DD ` .
19
- - ` end ` (optional): A string representing the end date in the format ` YYYY-MM-DD ` .
82
+ Returns a JSON object with the following schema:
20
83
21
- #### Response
84
+ ` ` ` json
85
+ [
86
+ {
87
+ " technology" : " Smartsupp" ,
88
+ " category" : " Live chat" ,
89
+ " description" : " Smartsupp is a live chat tool that offers visitor recording feature." ,
90
+ " icon" : " Smartsupp.svg" ,
91
+ " origins" : {
92
+ " mobile" : 24115,
93
+ " desktop" : 20250
94
+ }
95
+ }
96
+ ]
97
+ ` ` `
22
98
23
99
` ` ` bash
24
100
curl --request GET \
25
- --url ' https://{{HOST}}/v1/adoption?start=2023-01-01&end=2023-09-01&geo=Mexico&technology=GoCache&rank=ALL '
101
+ --url ' https://{{HOST}}/v1/technologies?onlyname '
26
102
` ` `
27
103
28
104
Returns a JSON object with the following schema:
29
105
30
106
` ` ` json
31
107
[
32
- {
33
- "technology" : " GoCache" ,
34
- "geo" : " Mexico" ,
35
- "date" : " 2023-06-01" ,
36
- "rank" : " ALL" ,
37
- "adoption" : {
38
- "mobile" : 19 ,
39
- "desktop" : 11
40
- }
41
- },
108
+ " 1C-Bitrix" ,
109
+ " 2B Advice" ,
110
+ " 33Across" ,
111
+ " 34SP.com" ,
112
+ " 4-Tell" ,
113
+ " 42stores" ,
114
+ " 51.LA" ,
115
+ " 5centsCDN" ,
42
116
...
43
- ]
117
+ }
44
118
` ` `
45
119
46
120
# ## `GET /categories`
47
121
48
- This endpoint can return a full list of categories names or a categories with all the associated technologies
49
-
50
- #### Parameters
122
+ Lists available categories.
51
123
52
- The following parameters can be used to filter the data:
124
+ # ### Categories Parameters
53
125
54
- - ` category ` (optional): A comma-separated string representing the category name(s).
55
- - ` onlyname ` (optional): No value required. If present, only the category names will be returned.
126
+ - ` category` (optional): Filter by category name(s) - comma-separated list
127
+ - ` onlyname` (optional): If present, returns only category names
56
128
57
- #### Response
129
+ # ### Categories Response
58
130
59
131
` ` ` bash
60
132
curl --request GET \
@@ -105,22 +177,58 @@ curl --request GET \
105
177
" Analytics" ,
106
178
...
107
179
]
180
+ ` ` `
181
+
182
+ # ## `GET /adoption`
183
+
184
+ Provides technology adoption data.
185
+
186
+ # ### Adoption Parameters
108
187
188
+ - ` technology` (required): Filter by technology name(s) - comma-separated list
189
+ - ` start` (optional): Filter by date range start (YYYY-MM-DD or ' latest' )
190
+ - ` end` (optional): Filter by date range end (YYYY-MM-DD)
191
+ - ` geo` (optional): Filter by geographic location
192
+ - ` rank` (optional): Filter by rank
193
+
194
+ # ### Adoption Response
195
+
196
+ ` ` ` bash
197
+ curl --request GET \
198
+ --url ' https://{{HOST}}/v1/adoption?start=2023-01-01&end=2023-09-01&geo=Mexico&technology=GoCache&rank=ALL'
109
199
` ` `
110
200
111
- ### ` GET /cwv `
201
+ Returns a JSON object with the following schema:
112
202
113
- #### Parameters
203
+ ` ` ` json
204
+ [
205
+ {
206
+ " technology" : " GoCache" ,
207
+ " geo" : " Mexico" ,
208
+ " date" : " 2023-06-01" ,
209
+ " rank" : " ALL" ,
210
+ " adoption" : {
211
+ " mobile" : 19,
212
+ " desktop" : 11
213
+ }
214
+ },
215
+ ...
216
+ ]
217
+ ` ` `
218
+
219
+ # ## `GET /cwv` (Core Web Vitals)
220
+
221
+ Provides Core Web Vitals metrics for technologies.
114
222
115
- The following parameters can be used to filter the data:
223
+ # ### CWV Parameters
116
224
117
- - ` geo ` (` required ` ): A string representing the geographic location.
118
- - ` technology ` (` required ` ): A string representing the technology name.
119
- - ` rank ` (` required ` ): An string representing the rank.
120
- - ` start ` (optional): A string representing the start date in the format ` YYYY-MM-DD ` .
121
- - ` end ` (optional): A string representing the end date in the format ` YYYY-MM-DD ` .
225
+ - ` technology ` (required): Filter by technology name(s) - comma-separated list
226
+ - ` geo ` (required): Filter by geographic location
227
+ - ` rank` (required): Filter by rank
228
+ - ` start` (optional): Filter by date range start ( YYYY-MM-DD or ' latest ' )
229
+ - ` end` (optional): Filter by date range end ( YYYY-MM-DD)
122
230
123
- #### Response
231
+ # ### CWV Response
124
232
125
233
` ` ` bash
126
234
curl --request GET \
@@ -151,22 +259,21 @@ curl --request GET \
151
259
]
152
260
}
153
261
]
154
-
155
262
` ` `
156
263
157
264
# ## `GET /lighthouse`
158
265
159
- #### Parameters
266
+ Provides Lighthouse scores for technologies.
160
267
161
- The following parameters can be used to filter the data:
268
+ # ### Lighthouse Parameters
162
269
163
- - ` technology ` (` required ` ): A comma-separated string representing the technology name(s).
164
- - ` geo ` (` required ` ): A string representing the geographic location.
165
- - ` rank ` (` required ` ): An string representing the rank.
166
- - ` start ` (optional): A string representing the start date in the format ` YYYY-MM-DD ` .
167
- - ` end ` (optional): A string representing the end date in the format ` YYYY-MM-DD ` .
270
+ - ` technology` (required): Filter by technology name(s) - comma-separated list
271
+ - ` geo` (required): Filter by geographic location
272
+ - ` rank` (required): Filter by rank
273
+ - ` start` (optional): Filter by date range start ( YYYY-MM-DD or ' latest ' )
274
+ - ` end` (optional): Filter by date range end ( YYYY-MM-DD)
168
275
169
- #### Response
276
+ # ### Lighthouse Response
170
277
171
278
` ` ` bash
172
279
curl --request GET \
@@ -205,17 +312,17 @@ Returns a JSON object with the following schema:
205
312
206
313
# ## `GET /page-weight`
207
314
208
- #### Parameters
315
+ Provides Page Weight metrics for technologies.
209
316
210
- The following parameters can be used to filter the data:
317
+ # ### Page Weight Parameters
211
318
212
- - ` geo ` (` required ` ): A string representing the geographic location.
213
- - ` technology ` (` required ` ): A comma-separated string representing the technology name(s).
214
- - ` rank ` (` required ` ): An string representing the rank.
215
- - ` start ` (optional): A string representing the start date in the format ` YYYY-MM-DD ` .
216
- - ` end ` (optional): A string representing the end date in the format ` YYYY-MM-DD ` .
319
+ - ` technology ` (required): Filter by technology name(s) - comma-separated list
320
+ - ` geo ` (optional ): Filter by geographic location
321
+ - ` rank` (optional ): Filter by rank
322
+ - ` start` (optional): Filter by date range start ( YYYY-MM-DD or ' latest ' )
323
+ - ` end` (optional): Filter by date range end ( YYYY-MM-DD)
217
324
218
- #### Response
325
+ # ### Page Weight Response
219
326
220
327
` ` ` bash
221
328
curl --request GET \
@@ -240,57 +347,41 @@ Returns a JSON object with the following schema:
240
347
]
241
348
` ` `
242
349
243
- ### ` GET /technologies `
350
+ # ## `GET /ranks `
244
351
245
- #### Parameters
352
+ Lists all available ranks.
246
353
247
- The following parameters can be used to filter the data:
354
+ # ## `GET /geos`
248
355
249
- - ` technology ` (optional): A comma-separated string representing the technology name(s) or ` ALL ` .
250
- - ` category ` (optional): A comma-separated string representing the category name(s).
251
- - ` onlyname ` (optional): No value required. If present, only the technology names will be returned.
356
+ Lists all available geographic locations.
252
357
253
- #### Response
358
+ # # Testing
254
359
255
360
` ` ` bash
256
- curl --request GET \
257
- --url ' https://{{HOST}}/v1/technologies?category=Live%20chat%2C%20blog&technology=Smartsupp'
361
+ # Run all tests
362
+ npm test
363
+
364
+ # Run tests with coverage
365
+ npm run test
258
366
` ` `
259
367
260
- Returns a JSON object with the following schema:
368
+ # # Response Format
369
+
370
+ All API responses follow this format:
261
371
262
372
` ` ` json
263
373
[
264
- {
265
- "technology" : " Smartsupp" ,
266
- "category" : " Live chat" ,
267
- "description" : " Smartsupp is a live chat tool that offers visitor recording feature." ,
268
- "icon" : " Smartsupp.svg" ,
269
- "origins" : {
270
- "mobile" : 24115 ,
271
- "desktop" : 20250
272
- }
273
- }
374
+ // Array of data objects
274
375
]
275
376
` ` `
276
377
277
- ``` bash
278
- curl --request GET \
279
- --url ' https://{{HOST}}/v1/technologies?onlyname'
280
- ```
281
-
282
- Returns a JSON object with the following schema:
378
+ Or in case of an error:
283
379
284
380
` ` ` json
285
- [
286
- " 1C-Bitrix" ,
287
- " 2B Advice" ,
288
- " 33Across" ,
289
- " 34SP.com" ,
290
- " 4-Tell" ,
291
- " 42stores" ,
292
- " 51.LA" ,
293
- " 5centsCDN" ,
294
- ...
381
+ {
382
+ " success" : false,
383
+ " errors" : [
384
+ {" key" : " error message" }
385
+ ]
295
386
}
296
387
` ` `
0 commit comments