/
PxAPI-2.yml
1728 lines (1678 loc) · 53.4 KB
/
PxAPI-2.yml
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: '3.0.2'
info:
title: PxApi
version: '2.0'
description: |
This api lets you do 2 things; Find a table(Navigation) and use a table (Table).
_Table below is added to show how tables can be described in yml._
**Table contains status code this API may return**
| Status code | Description | Reason |
| ------- | ----------- | --------------------- |
| 200 | Success | The endpoint has delivered response for the request |
| 400 | Bad request | If the request is not valid |
| 403 | Forbidden | number of cells exceed the API limit |
| 404 | Not found | If the URL in request does not exist |
| 429 | Too many request | Requests exceed the API time limit. Large queries should be run in sequence |
| 50X | Internal Server Error | The service might be down |
servers:
- url: https://api.server.test/api/v2
tags:
- name: Navigation
description: Find a table
- name: Table
description: Use a table
paths:
/navigation:
get:
tags:
- Navigation
summary: Get root Folder.
operationId: GetNavigationRoot
parameters:
- $ref: '#/components/parameters/lang'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/FolderResponse'
examples:
NavigateRoot:
$ref: './examplesAsYml/folder-root.yml#/folder-root'
'400':
$ref: '#/components/responses/ErrorResponse400'
'404':
$ref: '#/components/responses/ErrorResponse404'
'429':
$ref: '#/components/responses/ErrorResponse429'
/navigation/{id}:
get:
tags:
- Navigation
summary: Gets Folder by {id}.
operationId: GetNavigationById
parameters:
- $ref: '#/components/parameters/id'
- $ref: '#/components/parameters/lang'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/FolderResponse'
examples:
Navigation-BE:
$ref: './examplesAsYml/folder-be.yml#/folder-be'
'400':
$ref: '#/components/responses/ErrorResponse400'
'404':
$ref: '#/components/responses/ErrorResponse404'
'429':
$ref: '#/components/responses/ErrorResponse429'
/tables:
get:
tags:
- Table
summary: Get all Tables.
operationId: ListAllTables
parameters:
- $ref: '#/components/parameters/lang'
- $ref: '#/components/parameters/query'
- $ref: '#/components/parameters/pastDays'
- $ref: '#/components/parameters/include_discontinued'
- $ref: '#/components/parameters/pageNumber'
- $ref: '#/components/parameters/pageSize'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/TablesResponse'
examples:
tables:
$ref: './examplesAsYml/tablesResponse.yml#/tablesResponse'
/tables/{id}:
get:
tags:
- Table
summary: Get Table by {id}.
operationId: GetTableById
parameters:
- $ref: '#/components/parameters/lang'
- $ref: '#/components/parameters/id'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/TableResponse'
'400':
$ref: '#/components/responses/ErrorResponse400'
'404':
$ref: '#/components/responses/ErrorResponse404'
'429':
$ref: '#/components/responses/ErrorResponse429'
/tables/{id}/metadata:
get:
tags:
- Table
summary: Get Metadata about Table by {id}.
description: |
**Used for listing detailed information about a specific table**
* List all variables and values and all other metadata needed to be able to fetch data
* Also links to where to:
+ Fetch
- Where to get information about codelists
* 2 output formats
+ Custom json
- JSON-stat2
operationId: GetMetadataById
parameters:
- $ref: '#/components/parameters/lang'
- $ref: '#/components/parameters/id'
- $ref: '#/components/parameters/metadataOutputFormat'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/TableMetadataResponse'
examples:
TableMetadata:
$ref: './examplesAsYml/tableMetadata.yml#/tableMetadata'
application/jsonstat:
schema:
$ref: '#/components/schemas/Dataset'
examples:
Dataset-meta:
$ref: './examplesAsYml/dataset-meta.yml#/dataset-meta'
application/vnd.json-stat2+json:
schema:
externalDocs:
url: "https://json-stat.org/schema/"
'400':
$ref: '#/components/responses/ErrorResponse400'
'404':
$ref: '#/components/responses/ErrorResponse404'
'429':
$ref: '#/components/responses/ErrorResponse429'
/tables/{id}/defaultselection:
get:
tags:
- Table
summary: Get the default selection for Table by {id}.
description: Get information about what is selected for the table by default when no selection is made i the /data endpoint.
operationId: GetDefaultSelection
parameters:
- $ref: '#/components/parameters/lang'
- $ref: '#/components/parameters/id'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/SelectionResponse'
'400':
$ref: '#/components/responses/ErrorResponse400'
'404':
$ref: '#/components/responses/ErrorResponse404'
'429':
$ref: '#/components/responses/ErrorResponse429'
/codelists/{id}:
get:
tags:
- Table
summary: Get Codelist by {id}.
operationId: GetTableCodeListById
parameters:
- $ref: '#/components/parameters/lang'
- $ref: '#/components/parameters/id'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/CodeListResponse'
'400':
$ref: '#/components/responses/ErrorResponse400'
'404':
$ref: '#/components/responses/ErrorResponse404'
'429':
$ref: '#/components/responses/ErrorResponse429'
/tables/{id}/data:
get:
tags:
- Table
summary: Get data from table by {id}.
operationId: GetTableData
parameters:
- $ref: '#/components/parameters/lang'
- $ref: '#/components/parameters/id'
- in: query
name: valuecodes
schema:
type: object
additionalProperties:
type: array
items:
type: string
example: |
[
{"variable_1": "1,2,3"},
{"variable_2": "top(5)"}
]
style: deepObject
explode: true
- in: query
name: codelist
schema:
type: object
additionalProperties:
type: string
example: |
[
{"variable_1": "NUTS_2008"}
]
style: deepObject
explode: true
- in: query
name: outputvalues
schema:
type: object
additionalProperties:
$ref: '#/components/schemas/CodeListOutputValuesType'
example: |
[
{"variable_1": "single"}
]
style: deepObject
explode: true
- in: query
name: outputFormat
schema:
type: string
responses:
'200':
description: Success
content:
application/json:
schema:
type: string
plain/text:
schema:
type: string
application/xml:
schema:
type: string
format: binary
application/octet-stream:
schema:
type: string
format: binary
'400':
$ref: '#/components/responses/ErrorResponse400'
'403':
$ref: '#/components/responses/ErrorResponse403'
'404':
$ref: '#/components/responses/ErrorResponse404'
'429':
$ref: '#/components/responses/ErrorResponse429'
post:
tags:
- Table
summary: Get data from table by {id}.
operationId: GetTableDataByPost
parameters:
- $ref: '#/components/parameters/lang'
- $ref: '#/components/parameters/id'
- in: query
name: outputFormat
schema:
type: string
requestBody:
description: A selection
content:
application/json:
schema:
$ref: '#/components/schemas/VariablesSelection'
responses:
'200':
description: Success
content:
application/json:
schema:
type: string
plain/text:
schema:
type: string
application/xml:
schema:
type: string
format: binary
application/octet-stream:
schema:
type: string
format: binary
'400':
$ref: '#/components/responses/ErrorResponse400'
'403':
$ref: '#/components/responses/ErrorResponse403'
'404':
$ref: '#/components/responses/ErrorResponse404'
'429':
$ref: '#/components/responses/ErrorResponse429'
/config:
get:
tags:
- Configuration
summary: Get API configuration settings.
operationId: GetApiConfiguration
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/ConfigResponse'
'400':
$ref: '#/components/responses/ErrorResponse400'
'404':
$ref: '#/components/responses/ErrorResponse404'
'429':
$ref: '#/components/responses/ErrorResponse429'
components:
parameters:
lang:
name: lang
in: query
description: The language if the default is not what you want.
required: false
schema:
type: string
nullable: true
examples:
X1:
value: en
summary: For english
X2:
value: dk
summary: For danish
id:
name: id
in: path
description: Id
required: true
schema:
type: string
codeListId:
name: codeListId
in: path
description: Identifier for a code list
required: true
schema:
type: string
query:
name: query
in: query
description: Selects only tables that that matches a criteria which is specified by the search parameter.
required: false
schema:
type: string
examples:
X1:
value: befolkning
summary: Search for tables with name `befolkning`
pastDays:
name: pastDays
in: query
description: Selects only tables that was updated from the time of execution going back number of days stated by the parameter pastDays. Valid values for past days are integers between 1 and ?
required: false
schema:
type: integer
minimum: 1
examples:
X1:
value: 5
summary: Search for tables which has been updated in the last 5 days
include_discontinued:
name: includeDiscontinued
in: query
description: Decides if discontinued tables are included in response.
required: false
schema:
type: boolean
default: false
example: false
pageNumber:
name: pageNumber
in: query
description: "Pagination: Decides which page number to return"
required: false
schema:
type: integer
default: 1
pageSize:
name: pageSize
in: query
description: "Pagination: Decides how many tables per page"
required: false
schema:
type: integer
#Default value depends on site?
metadataOutputFormat:
name: outputFormat
in: query
description: The format of the resulting metadata
required: false
schema:
$ref: '#/components/schemas/MetadataOutputFormatType'
schemas:
VariablesSelection:
type: object
required:
- "selection"
properties:
selection:
type: array
items:
$ref: '#/components/schemas/VariableSelection'
SelectionResponse:
type: object
required:
- "language"
- "selection"
- "links"
properties:
language:
type: string
description: The language code for the language used in this response
example: sv
selection:
$ref: '#/components/schemas/VariablesSelection'
links:
type: array
items:
$ref: '#/components/schemas/Link'
VariableSelection:
type: object
required:
- "variableCode"
- "values"
properties:
variableCode:
type: string
description: The variable code.
codeList:
type: string
description: The identifier of the codelist that should be applied
nullable: true
outputValues:
$ref: '#/components/schemas/CodeListOutputValuesType'
description: If an codelist has been applied then how the resulting values should be constructed.
default: Aggregated
nullable: true
valueCodes:
type: array
description: An array of string that specifies wich values sould be selected. Either as value codes or value expressions
items:
type: string
MetadataOutputFormatType:
type: string
enum:
- json-px
- json-stat2
ConfigResponse:
type: object
description: API configuration
required:
- "apiVersion"
- "languages"
- "defaultLanguage"
- "maxDataCells"
- "maxCallsPerTimeWindow"
- "timeWindow"
- "license"
- "defaultMetadataFormat"
- "defaultDataFormat"
- "dataFormats"
properties:
apiVersion:
type: string
description: The version of then API
languages:
type: array
description: A list of language that exists for the data.
items:
$ref: '#/components/schemas/Language'
defaultLanguage:
type: string
description: The id of the language that is the default language.
maxDataCells:
type: integer
description: A threshold of how many datacells that can be fetched in a single API call
minimum: 0
maxCallsPerTimeWindow:
type: integer
description: The maximum number of call to the API for a time window indicated by timeWindow.
minimum: 1
timeWindow:
type: integer
description: The time window restricting how many call that can be done.
minimum: 1
license:
type: string
description: The license that the data is provided.
sourceReferences:
type: array
description: A list of how the data should be cite for diffrent languages.
items:
$ref: '#/components/schemas/SourceReference'
defaultMetadataFormat:
$ref: '#/components/schemas/MetadataOutputFormatType'
description: The default metadata format to used when no format is specified in the request.
defaultDataFormat:
type: string
description: The default data format to used when no format is specified in the request.
dataFormats:
type: array
description: List of available data formts for fetching data in.
items:
type: string
features:
type: array
description: A list of features for the API
items:
$ref: '#/components/schemas/ApiFeature'
Language:
type: object
description: Language information
required:
- "id"
- "label"
properties:
id:
type: string
description: The language ISO code
label:
type: string
description: The name of the language
SourceReference:
type: object
description: How data should be cite for a specific language
required:
- "language"
- "text"
properties:
language:
type: string
description: The language id
text:
type: string
description: The text that should be displayed
ApiFeature:
type: object
required:
- "id"
properties:
id:
type: string
description: The identifyer for the feature
params:
type: array
items:
$ref: '#/components/schemas/KeyValuePair'
KeyValuePair:
type: object
required:
- "key"
- "value"
properties:
key:
type: string
description: The key
value:
type: string
description: The value associated with the key
CodeListOutputValuesType:
type: string
enum:
- aggregated
- single
FolderContentItemTypeEnum:
type: string
enum:
- Heading
- FolderInformation
- Table
FolderContentItem:
discriminator:
propertyName: objectType
mapping:
Heading: "#/components/schemas/Heading"
FolderInformation: "#/components/schemas/FolderInformation"
Table: "#/components/schemas/Table"
type: object
description: Navigation item.
required:
- "type"
- "id"
- "label"
properties:
type:
$ref: '#/components/schemas/FolderContentItemTypeEnum'
description: One of Heading, Table or FolderInformation
nullable: false
id:
type: string
nullable: false
label:
type: string
nullable: true
description: Display text
description:
type: string
nullable: true
description: Longer text describing node.
sortCode:
type: string
description: String for sorting the contents in folder
FolderResponse:
type: object
description: Folder item
required:
- "language"
- "id"
- "label"
- "folderContents"
- "links"
properties:
language:
type: string
description: The language code (ISO 639) for this response
id:
type: string
nullable: true
#nullable = true beacause root is empty
label:
type: string
nullable: true
description: Display text
description:
type: string
nullable: true
description: Longer text describing node.
tags:
type: array
items:
type: string
description: tag for folder
folderContents:
type: array
items:
$ref: '#/components/schemas/FolderContentItem'
nullable: true
links:
type: array
items:
$ref: '#/components/schemas/Link'
description: Links to ...
nullable: true
FolderInformation:
allOf:
- $ref: '#/components/schemas/FolderContentItem'
type: object
description: Folder information item
required:
- "links"
properties:
tags:
type: array
items:
type: string
description: tag for folder
links:
type: array
items:
$ref: '#/components/schemas/Link'
description: Links to ...
nullable: true
Heading:
allOf:
- $ref: '#/components/schemas/FolderContentItem'
type: object
description: Heading item
TableResponse:
allOf:
- $ref: '#/components/schemas/Table'
required:
- "language"
properties:
language:
type: string
description: The language code (ISO 639) for this response
Table:
allOf:
- $ref: '#/components/schemas/FolderContentItem'
type: object
description: Table item
required:
- "updated"
- "firstPeriod"
- "lastPeriod"
- "variableNames"
- "links"
properties:
tags:
type: array
items:
type: string
description: tag for table
updated:
type: string
description: Date and time when the figures in the table was last updated, in UTC time.
pattern: "^((19|20)\\d\\d)\\-(0?[1-9]|1[012])\\-(0?[1-9]|[12][0-9]|3[01])$"
format: date-time
nullable: true
firstPeriod:
type: string
description: First period
example: 2017
nullable: true
lastPeriod:
type: string
description: Last period
example: 2022
nullable: true
category:
type: string
description: Mostly for internal use. Which category table belongs to. internal, public, private or section.
default: public
enum:
- internal
- public
- private
- section
variableNames:
type: array
description: List of varibles name
items:
type: string
discontinued:
type: boolean
nullable: true
links:
type: array
items:
$ref: '#/components/schemas/Link'
description: Links to ...
nullable: true
PageInfo:
type: object
required:
- "pageNumber"
- "pageSize"
- "totalElements"
- "totalPages"
properties:
pageNumber:
type: integer
description: The current page number.
format: int32
minimum: 1
pageSize:
type: integer
format: int32
description: The maximal number of elements in a page
example: 100
minimum: 1
totalElements:
type: integer
format: int32
description: the Total number of elements
minimum: 0
totalPages:
type: integer
format: int32
description: The total number of pages
minimum: 1
links:
type: array
items:
$ref: '#/components/schemas/Link'
TablesResponse:
type: object
required:
- "language"
- "tables"
- "page"
properties:
language:
type: string
description: The language code (ISO 639) for this response
tables:
type: array
items:
$ref: '#/components/schemas/Table'
page:
$ref: '#/components/schemas/PageInfo'
links:
type: array
items:
$ref: '#/components/schemas/Link'
VariableTypeEnum:
type: string
enum:
- ContentsVariable
- TimeVariable
- GeographicalVariable
- RegularVariable
TableMetadataResponse:
type: object
required:
- "language"
- "id"
- "label"
- "variables"
- "links"
properties:
language:
type: string
description: The language code (ISO 639) for this response
id:
type: string
description: Identifier for the table.
example: "TAB0001"
label:
type: string
description: A title for the table that describes the content of it.
example: Corporations Financial Assets and Liabilities. Quarterly 1998K2 - 2021K4
description:
type: string
description: A description of the table.
example: Corporations Financial Assets and Liabilities by item. Quarterly 1998K2 - 2021K4 [2022-03-11]
aggregationAllowed:
type: boolean
description: If all content of the table can be aggregated.
officialStatistics:
type: boolean
description: A marker if the table is a part of the national official statistics.
subjectCode:
type: string
description: The code for the subject area that the table belongs to.
example: BE
subjectLabel:
type: string
description: The label for the subject area that the table belongs to.
example: Population
source:
type: string
description: The name of the organization responsible for the table.
example: Statistics Sweden
license:
type: string
description: A copyright statement for the data it could also be SPDX (https://spdx.org/licenses/) identifier
example: CC0-1.0
tags:
type: array
description: A list of strings/tags associated with the table
items:
type: string
updated:
type: string
description: Date and time when the figures in the table was last updated, in UTC time.
pattern: "^((19|20)\\d\\d)\\-(0?[1-9]|1[012])\\-(0?[1-9]|[12][0-9]|3[01])$"
format: date-time
nullable: true
discontinued:
type: boolean
description: If the table is discontinued or not. That is if it no longer updated with new figures.
nullable: true
notes:
type: array
description: A list of notes associated with the table as a whole or a specific area of the table
items:
$ref: '#/components/schemas/CellNote'
contacts:
type: array
description: A list of contacts associated with the table.
items:
$ref: '#/components/schemas/Contact'
variables:
type: array
items:
$ref: '#/components/schemas/AbstractVariable'
links:
type: array
items:
$ref: '#/components/schemas/Link'
AbstractVariable:
discriminator:
propertyName: type
mapping:
ContentsVariable: "#/components/schemas/ContentsVariable"
TimeVariable: "#/components/schemas/TimeVariable"
GeographicalVariable: "#/components/schemas/GeographicalVariable"
RegularVariable: "#/components/schemas/RegularVariable"
type: object
required:
- id
- label
- type
properties:
id:
type: string
example: impex01
label:
type: string
example: Import and export
type:
$ref: '#/components/schemas/VariableTypeEnum'
notes:
type: array
items:
$ref: '#/components/schemas/Note'
links:
type: array
items:
$ref: '#/components/schemas/Link'
Note:
type: object
required:
- "text"
properties:
mandatory:
type: boolean
default: false
description: Must be shown to end user if true
text:
type: string
CellNote:
allOf:
- $ref: '#/components/schemas/Note'
type: object
description: Note for a table or a part of it
properties:
conditions:
type: array
description: A set of condition that must be fulfilled for the note to be valid.
items:
$ref: '#/components/schemas/Condition'
nullable: true
Condition: