Skip to content

Commit d9f1a0c

Browse files
committed
audits endpoint
1 parent 256f07f commit d9f1a0c

File tree

5 files changed

+87
-8
lines changed

5 files changed

+87
-8
lines changed

README.md

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ Lists available versions.
174174
175175
#### Versions Parameters
176176
177-
- `version` (optional): Filter by version name(s) - comma-separated list
178177
- `technology` (optional): Filter by technology name(s) - comma-separated list
179178
- `category` (optional): Filter by category - comma-separated list
179+
- `version` (optional): Filter by version name(s) - comma-separated list
180180
- `onlyname` (optional): If present, returns only version names
181181
- `fields` (optional): Comma-separated list of fields to include in the response (see [Field Selection API Documentation](#field-selection-api-documentation) for details)
182182
@@ -209,10 +209,10 @@ Provides technology adoption data.
209209
#### Adoption Parameters
210210
211211
- `technology` (required): Filter by technology name(s) - comma-separated list
212+
- `geo` (required): Filter by geographic location
213+
- `rank` (required): Filter by rank
212214
- `start` (optional): Filter by date range start (YYYY-MM-DD or 'latest')
213215
- `end` (optional): Filter by date range end (YYYY-MM-DD)
214-
- `geo` (optional): Filter by geographic location
215-
- `rank` (optional): Filter by rank
216216
217217
#### Adoption Response
218218
@@ -334,8 +334,8 @@ Provides Page Weight metrics for technologies.
334334
#### Page Weight Parameters
335335
336336
- `technology` (required): Filter by technology name(s) - comma-separated list
337-
- `geo` (optional): Filter by geographic location
338-
- `rank` (optional): Filter by rank
337+
- `geo` (required): Filter by geographic location
338+
- `rank` (required): Filter by rank
339339
- `start` (optional): Filter by date range start (YYYY-MM-DD or 'latest')
340340
- `end` (optional): Filter by date range end (YYYY-MM-DD)
341341
@@ -387,6 +387,70 @@ Returns a JSON object with the following schema:
387387
]
388388
```
389389
390+
391+
### `GET /audits`
392+
393+
Provides Lighthouse audits for technologies.
394+
395+
#### Audits Parameters
396+
397+
- `technology` (required): Filter by technology name(s) - comma-separated list
398+
- `geo` (required): Filter by geographic location
399+
- `rank` (required): Filter by rank
400+
- `start` (optional): Filter by date range start (YYYY-MM-DD or 'latest')
401+
- `end` (optional): Filter by date range end (YYYY-MM-DD)
402+
403+
#### Audits Response
404+
405+
```bash
406+
curl --request GET \
407+
--url 'https://{{HOST}}/v1/audits?start=latest&geo=ALL&technology=WordPress&rank=ALL'
408+
```
409+
410+
Returns a JSON object with the following schema:
411+
412+
```json
413+
[
414+
{
415+
"date": "2025-06-01",
416+
"audits": [
417+
{
418+
"desktop": {
419+
"pass_origins": 2428028
420+
},
421+
"mobile": {
422+
"pass_origins": 2430912
423+
},
424+
"id": "first-contentful-paint",
425+
"category": "performance"
426+
},
427+
{
428+
"desktop": {
429+
"pass_origins": 490451
430+
},
431+
"mobile": {
432+
"pass_origins": 477218
433+
},
434+
"id": "largest-contentful-paint",
435+
"category": "performance"
436+
},
437+
{
438+
"desktop": {
439+
"pass_origins": 1221876
440+
},
441+
"mobile": {
442+
"pass_origins": 1296673
443+
},
444+
"id": "cumulative-layout-shift",
445+
"category": "performance"
446+
}
447+
],
448+
"technology": "WordPress"
449+
},
450+
...
451+
]
452+
```
453+
390454
### `GET /ranks`
391455
392456
Lists all available ranks.

src/controllers/reportController.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ const REPORT_CONFIGS = {
3232
cwv: {
3333
table: 'core_web_vitals',
3434
dataField: 'vitals'
35+
},
36+
audits: {
37+
table: 'audits',
38+
dataField: 'audits'
3539
}
3640
};
3741

@@ -146,7 +150,10 @@ const createReportController = (reportType) => {
146150
};
147151

148152
// Export individual controller functions
153+
export const listAuditsData = createReportController('audits');
149154
export const listAdoptionData = createReportController('adoption');
150-
export const listPageWeightData = createReportController('pageWeight');
151-
export const listLighthouseData = createReportController('lighthouse');
152155
export const listCWVTechData = createReportController('cwv');
156+
export const listLighthouseData = createReportController('lighthouse');
157+
export const listPageWeightData = createReportController('pageWeight');
158+
159+

src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const controllers = {
1111
cwvtech: null,
1212
lighthouse: null,
1313
pageWeight: null,
14+
audits: null,
1415
ranks: null,
1516
geos: null,
1617
versions: null
@@ -30,6 +31,7 @@ const getController = async (name) => {
3031
case 'cwvtech':
3132
case 'lighthouse':
3233
case 'pageWeight':
34+
case 'audits':
3335
controllers[name] = await import('./controllers/reportController.js');
3436
break;
3537
case 'ranks':
@@ -144,6 +146,9 @@ const handleRequest = async (req, res) => {
144146
} else if (pathname === '/v1/page-weight' && req.method === 'GET') {
145147
const { listPageWeightData } = await getController('pageWeight');
146148
await listPageWeightData(req, res);
149+
} else if (pathname === '/v1/audits' && req.method === 'GET') {
150+
const { listAuditsData } = await getController('audits');
151+
await listAuditsData(req, res);
147152
} else if (pathname === '/v1/ranks' && req.method === 'GET') {
148153
const { listRanks } = await getController('ranks');
149154
await listRanks(req, res);

terraform/modules/run-service/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
locals {
2-
bucketName = "tf-cloudfunctions-backingapi-20230314"
2+
bucketName = "gcf-v2-uploads-226352634162-us-central1"
33
}
44
data "archive_file" "source" {
55
type = "zip"

test-api.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,7 @@ test_endpoint "/v1/lighthouse" "?technology=WordPress&geo=ALL&rank=ALL&start=lat
113113
# Test page-weight endpoint
114114
test_endpoint "/v1/page-weight" "?technology=WordPress&geo=ALL&rank=ALL&start=latest"
115115

116+
# Test audits endpoint
117+
test_endpoint "/v1/audits" "?technology=WordPress&geo=ALL&rank=ALL&start=latest"
118+
116119
echo "API tests complete! All endpoints returned 200 status code and CORS is properly configured."

0 commit comments

Comments
 (0)