-
Notifications
You must be signed in to change notification settings - Fork 7
/
openapi.yaml
336 lines (335 loc) · 9.82 KB
/
openapi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
openapi: 3.0.0
info:
title: GOV.UK Content Data API
description: |
GOV.UK Content Data API provides metrics about GOV.UK content.
This API accepts HTTP requests and responds with
[JSON](https://en.wikipedia.org/wiki/JSON).
version: 1.0.0
servers:
- url: 'https://content-data-api.publishing.service.gov.uk/api/v1'
description: Production
- url: 'https://content-data-api.staging.publishing.service.gov.uk/api/v1'
description: Staging
- url: 'https://content-data-api.integration.publishing.service.gov.uk/api/v1'
description: Integration
- url: 'http://content-data-api.dev.gov.uk/api/v1'
description: Development
paths:
'/organisations/':
get:
summary: Get all organisations
responses:
'200':
description: A list of organisations
content:
application/json:
schema:
$ref: '#/components/schemas/ArrayOfOrganisations'
'/document_types/':
get:
summary: Get all document types
responses:
'200':
description: A list of document types
content:
application/json:
schema:
$ref: '#/components/schemas/ArrayOfDocumentTypes'
'/metrics/':
get:
summary: List all available metrics.
description: |
Returns a list of available metrics for content items.
tags:
- Metadata
responses:
'200':
description: |
Success response
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Metric'
example:
$ref: '#/components/examples/MetricsExample'
x-code-samples:
/metrics/:
lang: shell
source: >-
curl
'https://content-data-api.publishing.service.gov.uk/api/v1/metrics/'
'/metrics/{base_path}':
get:
summary: Get summarised metrics for a content item.
description: >
Returns a summary of a metric based on data collected over a time
period.
tags:
- Aggregations
parameters:
- name: base_path
in: path
required: true
description: >
A GOV.UK base path. A reserved URL on www.gov.uk that is associated
with a content item.
schema:
type: string
example: /vat-rates
- name: metrics
in: path
required: true
description: |
The names of metrics.
schema:
type: string
example: pviews
- name: from
in: query
required: true
description: >
From date in the format 'YYYY-MM-DD'. Only data collected on or
after this date will be included.
schema:
type: string
example: '2018-01-01'
- name: to
in: query
required: true
description: >
To date in the format 'YYYY-MM-DD'. Only data collected on or before
this date will be included.
schema:
type: string
example: '2018-01-01'
responses:
'200':
description: |
Success response
content:
application/json:
schema:
$ref: '#/components/schemas/SummaryResponse'
'400':
description: The API request is invalid.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
x-code-samples:
/metrics/f838c22a-b2aa-49be-bd95-153f593293a3:
lang: shell
source: >-
curl
'https://content-data-api.publishing.service.gov.uk/api/v1/metrics/vat-rates?from=2018-02-27&to=2018-02-27&metrics[]=upviews&metrics[]=pviews'
'/metrics/{base_path}/time-series':
get:
summary: Get metric values for a single content item over a date range.
description: |
Returns an array of values for each metric. Each item represents a
metric value at a single point in time.
tags:
- Time series
parameters:
- name: base_path
in: path
required: true
description: >
A GOV.UK base path. A reserved URL on www.gov.uk that is associated
with a content item.
schema:
type: string
example: /vat-rates
- name: metrics
in: path
required: true
description: |
The names of metrics.
schema:
type: string
example: pviews
- name: from
in: query
required: true
description: >
From date in the format 'YYYY-MM-DD'. Only data collected on or
after this date will be returned.
schema:
type: string
example: '2018-01-01'
- name: to
in: query
required: true
description: >
To date in the format 'YYYY-MM-DD'. Only data collected on or before
this date will be returned.
schema:
type: string
example: '2018-01-01'
responses:
'200':
description: |
Success response
content:
application/json:
schema:
$ref: '#/components/schemas/TimeSeriesResponse'
'400':
description: The API request is invalid.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
$ref: '#/components/examples/ErrorExample'
x-code-samples:
/metrics/vat-rates:
lang: shell
source: >-
curl
'https://content-data-api.publishing.service.gov.uk/api/v1/metrics/vat-rates/time-series?from=2018-02-27&to=2018-02-27&metrics[]=upviews&metrics[]=pviews'
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
schemas:
Organisation:
requires:
- id
- name
properties:
id:
type: string
name:
type: string
ArrayOfOrganisations:
type: array
items:
$ref: '#/components/schemas/Organisation'
DocumentType:
requires:
- id
- name
properties:
id:
type: string
name:
type: string
ArrayOfDocumentTypes:
type: array
items:
$ref: '#/components/schemas/DocumentType'
Metric:
description: |
Information about a metric returned by the API.
type: object
required:
- metric_id
- description
properties:
metric_id:
type: string
description: ID to refer to the metric within the API
description:
type: string
description: Description of the metric
source:
type: string
description: Where this metric comes from
Summary:
description: |
Summarised metric data for a defined time period
type: object
required:
- total
- latest
properties:
total:
type: integer
description: Sum of all recorded metric values within the date range.
latest:
type: integer
description: The latest recorded metric value within the date range.
Value:
description: |
A single observation of a metric.
type: object
required:
- date
- value
properties:
date:
type: string
description: Date of measurement, in the form YYYY-MM-DD.
value:
type: integer
description: The value of the metric.
TimeSeries:
description: |
A series of values for a metric.
type: array
items:
$ref: '#/components/schemas/Value'
TimeSeriesResponse:
description: An object where each key is a metric ID and each value is a time series.
type: object
additionalProperties:
$ref: '#/components/schemas/TimeSeries'
SummaryResponse:
description: Summary information keyed by metric ID.
type: object
additionalProperties:
$ref: '#/components/schemas/Summary'
ErrorResponse:
description: An error response.
type: object
required:
- title
- type
properties:
title:
type: string
description: A human readable summary of the error.
invalid_params:
type: object
description: An array of error messages for each invalid parameter.
type:
type: string
description: A URI identifying the error.
example:
$ref: '#/components/examples/ErrorExample'
examples:
ErrorExample:
summary: An example of an error.
value:
title: One or more parameters is invalid
invalid_params:
from:
- can't be blank
- Dates should use the format YYYY-MM-DD
to:
- can't be blank
- Dates should use the format YYYY-MM-DD
type: >-
https://content-data-api.publishing.service.gov.uk/errors.html#validation-error
MetricsExample:
summary: An list of available metrics.
value:
- description: Number of pageviews
source: Google Analytics
metric_id: pviews
- description: Number of unique pageviews
source: Google Analytics
metric_id: upviews
- description: Number of reported content issues
source: Feedback explorer
metric_id: feedex
- description: Number of .pdf attachments
source: Publishing API
metric_id: pdf_count
security:
- bearerAuth: []