From 642831e09da641381680e58600f424da994a61b4 Mon Sep 17 00:00:00 2001 From: Ian leggett <> Date: Thu, 20 Jun 2024 16:55:49 +0100 Subject: [PATCH] reorganise templates and pages --- app.py | 4 +- templates/accessibility_statement.html | 109 --- templates/docs.html | 700 ------------------- templates/filter_columns.html | 2 +- templates/filter_rows.html | 2 +- templates/index.html | 619 ++++++++++++++++ templates/{ => layouts}/base.html | 0 templates/layouts/docs.html | 45 ++ templates/layouts/page.html | 32 + templates/metadata.html | 2 +- templates/pages/accessibility_statement.html | 22 + templates/partials/footer.html | 22 + templates/partials/header.html | 22 + templates/partials/navigation.html | 68 ++ 14 files changed, 835 insertions(+), 814 deletions(-) delete mode 100644 templates/accessibility_statement.html delete mode 100644 templates/docs.html create mode 100644 templates/index.html rename templates/{ => layouts}/base.html (100%) create mode 100644 templates/layouts/docs.html create mode 100644 templates/layouts/page.html create mode 100644 templates/pages/accessibility_statement.html create mode 100644 templates/partials/footer.html create mode 100644 templates/partials/header.html create mode 100644 templates/partials/navigation.html diff --git a/app.py b/app.py index b7ff98a9..0f43c14c 100644 --- a/app.py +++ b/app.py @@ -954,7 +954,7 @@ def docs(): ), 'security_email': os.environ.get('DOCS_SECURITY_EMAIL'), } - return render_template('docs.html', **context) + return render_template('index.html', **context) @track_analytics def accessibility_statement(): @@ -966,7 +966,7 @@ def accessibility_statement(): 'service_name': os.environ.get('DOCS_SERVICE_NAME'), 'base_url': request.base_url.rstrip('/'), } - return render_template('accessibility_statement.html', **context) + return render_template('pages/accessibility_statement.html', **context) app = Flask('app') diff --git a/templates/accessibility_statement.html b/templates/accessibility_statement.html deleted file mode 100644 index 1b732c14..00000000 --- a/templates/accessibility_statement.html +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - {{ service_name }} - {{ department_name }} - - - - - - - - - - - - - - - - -
-
- Skip to main content - - -
-
- -

Accessibility Statement

-

- The Department for Business and Trade digital team is committed to making sure our online services are accessible to all users and comply with level AA of the Web Content Accessibility Guidelines – WCAG 2.1, in line with The Public Sector Bodies (Websites and Mobile Applications) (No. 2) Accessibility Regulations 2018. -

-

- In order to help us achieve and maintain our objective, we have commissioned The Digital Accessibility Centre (DAC) to carry out WCAG 2.1 AA level technical compliance audits that also include extensive manual testing. -

-

- We anticipate the outcome of all tests to be complete by 16th December 2023. -

-

What to do if you cannot access parts of this website

-

- If you need information on this website in a different format, email Kathy.Gribbin@trade.gov.uk. If you have a problem with accessing any of the pages on this site you can contact us at data-workspace@uktrade.zendesk.com. We’ll get back to you within 5 working days. -

-

Reporting accessibility problems with this website

-

- We’re always looking to improve the accessibility of this website. - If you find any problems or think we’re not meeting the requirements of the accessibility regulations,
please tell us by contacting data-workspace@uktrade.zendesk.com. -

-
- -
-
-
- - - diff --git a/templates/docs.html b/templates/docs.html deleted file mode 100644 index 1f1924eb..00000000 --- a/templates/docs.html +++ /dev/null @@ -1,700 +0,0 @@ - - - - - - - {{ service_name }} - {{ department_name }} - - - - - - - - - - - - - - - - - -
-
- Skip to main content - - -
-
- -
-
- -
-
- -

{{ service_name }}

- -

The {{ department_name }} {{ service_name }} supplies datasets via HTTPS without authentication.

-
    -
  • Datasets are versioned
  • -
  • Each dataset version is immutable
  • -
  • Each dataset version has one or more tables
  • -
  • Each dataset version has zero or more reports - a report contains filtered or aggregated table data
  • -
  • Metadata for each dataset version is available as HTML or CSVW (CSV on the Web)
  • -
  • Data can be filtered or aggregated using the S3 Select query language
  • -
  • Data is supplied as SQLite, JSON, CSV, or ODS (OpenDocument Spreadsheet).
  • -
- -

The source code for the {{ service_name }} is available in its GitHub repository.

- -

Getting started

- -

Any tool that can make HTTPS requests can access the {{ service_name}}. Examples are curl, Postman, or the web browser you're currently using.

- -

For example {{ base_url }}/v1/datasets?format=json will return a list of datasets.

- -

Base URL

-

All requests to this API should be prefixed with the following URL.

-
{{ base_url }}
- -

Versioning

- -

Datasets are versioned according to a subset of the Semver 2.0 specification. Each version is of the form X.Y.Z, where X is the major version, Y is the minor version, and Z is the patch version. Each release of a dataset increments the version according to the following rules.

- -
    -
  • Patch: incremented when data is added or changed, but the structure of the data is the same.
  • -
  • Minor: incremented when new fields or tables are added to the data, but existing ones are unchanged.
  • -
  • Major: incremented when existing fields are removed or change type.
  • -
- -

Reports

- -

Datasets can contain reports. Reports are similar to tables, except that the data in reports is generated from the tables in the dataset. Reports are available to satisfy common use cases for filtered or aggregated views of the data in a dataset.

- -

If a dataset is available as SQLite, reports are generated using SQL in the _reports table in the SQLite file.

- -

Common parameters

- -

Several URL parameters are applicable to multiple API endpoints.

- - - - - - - - - - - - - - - - - - - - - - - - - - -
NameDescription
dataset_idA human-readable identifier of a dataset, e.g. {{ dataset }}
version_id -

A version identifier in the format vX.Y.Z, where X.Y.Z is the Semver 2.0 version of the dataset, e.g. {{ version }}

-

or

-

A version in the format vX.Y. In this case, a HTTP 302 redirect is returned to the URL requested, but with version_id equal to the latest version of the dataset with major and minor components matching vX.Y

-

or

-

A version in the format vX. In this case, a HTTP 302 redirect is returned to the URL requested, but with version_id equal to the latest version of the dataset with major component matching vX

-

or

-

The literal latest. In this case, a HTTP 302 redirect is returned to the URL requested, but with version_id equal to the latest version of the dataset

-
table_idA human-readable identifier of a table, e.g. {{ table_name }}
report_idA human-readable identifier of a report, e.g. {{ sample_dataset_with_report_report_name }}
- -

API Endpoints

- -

GET list of datasets

-

The list of all datasets available in the {{ service_name }} can be accessed using this endpoint.

-
GET /v1/datasets
-

Query string parameters

- - - - - - - - - - - - - - - -
NameRequiredDescription
formatYesThe requested output format. In all cases, this must be json
-

Example

-
Request
-
curl --get {{ base_url }}/v1/datasets \
-    --data-urlencode "format=json"
-
Response
-
Status: 200 OK
-{
-    "datasets": [
-        {"id": "market-barriers"}, {"id": "uk-tariff-2021-01-01"}
-    ]
-}
- -

GET list of versions of a dataset

-

The list of versions of each dataset can be accessed using this endpoint.

-
GET /v1/datasets/{dataset_id}/versions
-

Query string parameters

- - - - - - - - - - - - - - - -
NameRequiredDescription
formatYesThe requested output format. In all cases, this must be json
-

Example

-
Request
-
curl --get {{ base_url }}/v1/datasets/{{ dataset }}/versions \
-    --data-urlencode "format=json"
-
Response
-
Status: 200 OK
-{
-    "versions": [
-        {"id": "{{ latest_version }}"}, {"id": "{{ version }}"}
-    ]
-}
- -

GET list of tables in a version

-

The list of tables of each dataset version can be accessed using this endpoint.

-
GET /v1/datasets/{dataset_id}/versions/{version_id}/tables
-

Query string parameters

- - - - - - - - - - - - - - - -
NameRequiredDescription
formatYesThe requested output format. In all cases, this must be json
-

Example

-
Request
-
curl --get {{ base_url }}/v1/datasets/{{ dataset }}/versions/{{ version }}/tables \
-    --data-urlencode "format=json"
-
Response
-
Status: 200 OK
-{
-    "tables": [
-        {"id": "commodities"},
-        {"id": "measures-as-defined"},
-        {"id": "measures-on-declarable-commodities"}
-    ]
-}
- -

GET list of reports in a version

-

The list of reports of each dataset version can be accessed using this endpoint.

-
GET /v1/datasets/{dataset_id}/versions/{version_id}/reports
-

Query string parameters

- - - - - - - - - - - - - - - -
NameRequiredDescription
formatYesThe requested output format. In all cases, this must be json
-

Example

-
Request
-
curl --get {{ base_url }}/v1/datasets/{{ sample_dataset_with_report }}/versions/{{ sample_dataset_with_report_version }}/reports \
-    --data-urlencode "format=json"
-
Response
-
Status: 200 OK
-{
-    "reports": [
-        {"id": "quotas-including-current-volumes"}
-    ]
-}
- -

GET metadata of a version

-

The metadata of a dataset version can be accessed using this endpoint.

-
GET /v1/datasets/{dataset_id}/versions/{version_id}/metadata
-

Query string parameters

- - - - - - - - - - - - - - - - - - - - -
NameRequiredDescription
formatYesThe requested output format. This must be csvw or html
downloadNoThe presence of this parameter results in a content-disposition header so that browsers attempt to download the metadata rather than display it inline
-

Example requesting CSVW

-
Request
-
curl --get {{ base_url }}/v1/datasets/{{ dataset }}/versions/{{ version }}/metadata \
-    --data-urlencode "format=csvw"
-
Response (excerpt)
-
Status: 200 OK
-{
-  "@context": [
-    "http://www.w3.org/ns/csvw",
-    {"dit": "http://data.api.trade.gov.uk/"}
-  ],
-  "dc:title": "Tariffs to trade with the UK from 1 January 2021",
-  ...
-  "tables": [{
-    "id": "commodities",
-    ...
-    "tableSchema": {
-      "columns": [{
-        "name": "id",
-        ...
-      }, ...]
-    }
-  }, ...]
-}
- -

GET data in a version

-

All of the data of a dataset version can be accessed using this endpoint

-
GET /v1/datasets/{dataset_id}/versions/{version_id}/data
-

Query string parameters

- - - - - - - - - - - - - - - - - - - - - - - - - -
NameRequiredDescription
formatYesThe requested output format. This must be sqlite, json, or ods
query-s3-selectNo -

A query using the S3 Select query language, e.g. SELECT * FROM S3Object[*]

-

The response is a JSON object with the query results under the rows key, i.e. {"rows": [...]}

-

Using query-s3-select requires that the format parameter be json.

-
downloadNoThe presence of this parameter results in a content-disposition header so that browsers attempt to download the data rather than display it inline.
-

Range requests

-

If a query-s3-select is not specified, the range HTTP header can be passed to select a byte-range of the dataset. See HTTP Range Requests for more details.

-

Example without a query

-
Request
-
curl --get {{ base_url }}/v1/datasets/{{ dataset }}/versions/{{ version }}/data \
-    --data-urlencode "format=json"
-
Response (excerpt)
-
Status: 200 OK
-{
-    "commodities": [
-        {"id": "1", "commodity__code": "0100000000", ...
-        ...
-    ],
-    ...
-}
-

Example with a query

-
Request
-
curl --get https://data.api.trade.gov.uk/v1/datasets/uk-tariff-2021-01-01/versions/v2.1.0/data \
-    --data-urlencode "format=json" \
-    --data-urlencode "query-s3-select=
-        SELECT
-            c.commodity__code, c.commodity__suffix, c.commodity__description
-        FROM
-            S3Object[*].commodities[*] c
-        WHERE
-            c.commodity__code = '0101210000'
-        LIMIT
-            1
-    "
-
Response
-
Status: 200 OK
-{
-    "rows":[
-      {"commodity__code": "0101210000", "commodity__suffix": "10", "commodity__description": "Horses"}
-    ]
-}
- -

GET data in a table

-

The data of single table in a dataset version can be accessed using this endpoint.

-
GET /v1/datasets/{dataset_id}/versions/{version_id}/tables/{table_id}/data
-

Query string parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameRequiredDescription
formatYesThe requested output format. This must be csv or ods
query-s3-selectNo -

A query using the S3 Select query language, e.g. SELECT * FROM S3Object

-
query-simpleNo -

Enables a "simple" query mode to specify columns to retrieve, and filter rows using exact matching.

-

In simple mode, the value of each _columns parameter is a single column to include in the output. This parameter can be passed multiple times to include multiple columns.

-

Filtering on rows can then be performed by passing key value pairs column=value. The output includes only those rows where column column equals value.

-
downloadNoThe presence of this parameter results in a content-disposition header so that browsers attempt to download the data rather than display it inline.
-

Range requests

-

If query-s3-select and query-simple are not specified, the range HTTP header can be passed to select a byte-range of the table. See HTTP Range Requests for more details.

-

Example without a query

-
Request
-
curl --get {{ base_url }}/v1/datasets/{{ dataset }}/versions/{{ version }}/tables/{{ table_name }}/data \
-    --data-urlencode "format=csv"
-
Response
-
Status: 200 OK
-"id","commodity__sid","commodity__code","commodity__suffix","commodity__description","commodity__validity_start","commodity__validity_end","parent__sid","parent__code","parent__suffix"
-"1","27623","0100000000","80","LIVE ANIMALS","1971-12-31","#NA","#NA","#NA","#NA"
-"2","27624","0101000000","80","Live horses, asses, mules and hinnies","1972-01-01","#NA","27623","0100000000","80"
-"3","93797","0101210000","10","Horses","2012-01-01","#NA","27624","0101000000","80"
-
- -

Example with an S3 Select query

-
Request
-
curl --get {{ base_url }}/v1/datasets/{{ dataset }}/versions/{{ version }}/tables/{{ table_name }}/data \
-    --data-urlencode "format=csv" \
-    --data-urlencode "query-s3-select=
-        SELECT
-            c.commodity__code, c.commodity__suffix, c.commodity__description
-        FROM
-            S3Object c
-        WHERE
-            c.commodity__code = '0101210000'
-        LIMIT
-            1
-    "
- -
Response
-
Status: 200 OK
-0101210000,10,Horses
-
- -

Example with a simple query

-
Request
-
curl --get {{ base_url }}/v1/datasets/{{ dataset }}/versions/{{ version }}/tables/{{ table_name }}/data \
-    --data-urlencode "format=csv" \
-    --data-urlencode "query-simple" \
-    --data-urlencode "commodity__code=0101210000" \
-    --data-urlencode "_columns=commodity__code" \
-    --data-urlencode "_columns=commodity__suffix" \
-    --data-urlencode "_columns=commodity__description"
-
- -
Response
-
Status: 200 OK
-commodity__code,commodity__suffix,commodity__description
-0101210000,10,Horses
-0101210000,80,Pure-bred breeding animals
-
- -

GET data in a report

-

The data of a single report in a dataset version can be accessed using this endpoint.

-
GET /v1/datasets/{dataset_id}/versions/{version_id}/reports/{report_id}/data
-

Query string parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameRequiredDescription
formatYesThe requested output format. This must be csv or ods
query-s3-selectNo -

A query using the S3 Select query language, e.g. SELECT * FROM S3Object

-
query-simpleNo -

Enables a "simple" query mode to specify columns to retrieve, and filter rows using exact matching.

-

In simple mode, the value of each _columns parameter is a single column to include in the output. This parameter can be passed multiple times to include multiple columns.

-

Filtering on rows can then be performed by passing key value pairs column=value. The output includes only those rows where column column equals value.

-
downloadNoThe presence of this parameter results in a content-disposition header so that browsers attempt to download the data rather than display it inline.
-

Range requests

-

If query-s3-select and query-simple are not specified, the range HTTP header can be passed to select a byte-range of the report. See HTTP Range Requests for more details.

-

Example without a query

-
Request
-
curl --get {{ base_url }}/v1/datasets/{{ sample_dataset_with_report }}/versions/{{ sample_dataset_with_report_version }}/reports/{{ sample_dataset_with_report_report_name }}/data \
-    --data-urlencode "format=csv"
-
Response (excerpt)
-
Status: 200 OK
-"quota_definition__sid","quota__order_number","quota__geographical_areas","quota__headings","quota__commodities","quota__measurement_unit","quota__monetary_unit","quota_definition__description","quota_definition__validity_start_date","quota_definition__validity_end_date","quota_definition__suspension_periods","quota_definition__blocking_periods","quota_definition__status","quota_definition__last_allocation_date","quota_definition__initial_volume","quota_definition__balance","quota_definition__fill_rate"
-20815,50006,"ERGA OMNES","0302 – Fish, fresh or chilled, excluding fish fillets and other fish meat of heading|0304|0303 – Fish, frozen, excluding fish fillets and other fish meat of heading 0304|0304 – Fish fillets and other fish meat (whether or not minced), fresh, chilled or frozen","0302410000|0303510000|0304595000|0304599010|0304992300","Kilogram (kg)","#NA","#NA","2021-01-01","2021-02-14","#NA","#NA","Closed","2021-01-28",2022900,2022900.0,0.0
-20814,50006,"ERGA OMNES","0302 – Fish, fresh or chilled, excluding fish fillets and other fish meat of heading|0304|0303 – Fish, frozen, excluding fish fillets and other fish meat of heading 0304|0304 – Fish fillets and other fish meat (whether or not minced), fresh, chilled or frozen","0302410000|0303510000|0304595000|0304599010|0304992300","Kilogram (kg)","#NA","#NA","2021-06-16","2022-02-14","#NA","#NA","Open","#NA",2112000,2112000.0,0.0
-
- -

Example with an S3 Select query

-
Request
-
curl --get {{ base_url }}/v1/datasets/{{ sample_dataset_with_report }}/versions/{{ sample_dataset_with_report_version }}/reports/{{ sample_dataset_with_report_report_name }}/data \
-    --data-urlencode "format=csv" \
-    --data-urlencode "query-s3-select=
-        SELECT
-            q.quota__order_number, q.quota_definition__validity_start_date, q.quota_definition__status, q.quota_definition__initial_volume, q.quota_definition__balance
-        FROM
-            S3Object q
-        WHERE
-            q.quota__commodities LIKE '%0203195900%'
-    "
- -
Response
-
Status: 200 OK
-50123,2021-01-01,Exhausted,2000,0.0
-50123,2021-07-01,Open,1349000,1349000.0
-51921,2021-01-01,Open,1632000,1632000.0
-51944,2021-01-01,Critical,167000,147000.0
-57220,2021-01-01,Open,494000,494000.0
-59282,2021-01-01,Open,4838000,4838000.0
-
- -

Example with a simple query

-
Request
-
curl --get {{ base_url }}/v1/datasets/{{ sample_dataset_with_report }}/versions/{{ sample_dataset_with_report_version }}/reports/{{ sample_dataset_with_report_report_name }}/data \
-    --data-urlencode "format=csv" \
-    --data-urlencode "query-simple" \
-    --data-urlencode "quota__order_number=50123" \
-    --data-urlencode "_columns=quota__order_number" \
-    --data-urlencode "_columns=quota_definition__validity_start_date" \
-    --data-urlencode "_columns=quota_definition__status" \
-    --data-urlencode "_columns=quota_definition__initial_volume" \
-    --data-urlencode "_columns=quota_definition__balance"
-
- -
Response
-
Status: 200 OK
-quota__order_number,quota_definition__validity_start_date,quota_definition__status,quota_definition__initial_volume,quota_definition__balance
-50123,2021-01-01,Exhausted,2000,0.0
-50123,2021-07-01,Open,1349000,1349000.0
-
- -

Support

- -

For help with the {{ service_name }} please create an issue on its GitHub issues page.

- -

Security

- -

To report a security vulnerability please contact us at {{ security_email }}.

- -

Accessibility

- -

Please find the accessibility statement.

- -
- -
-
-
- - - diff --git a/templates/filter_columns.html b/templates/filter_columns.html index 75239741..f5d6734e 100644 --- a/templates/filter_columns.html +++ b/templates/filter_columns.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "layouts/base.html" %} {% block title %}Filter columns - {{ table_name }}{% endblock %} diff --git a/templates/filter_rows.html b/templates/filter_rows.html index 4ed80f8a..5a9dc8e2 100644 --- a/templates/filter_rows.html +++ b/templates/filter_rows.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "layouts/base.html" %} {% block title %}Filter rows - {{ table_name }}{% endblock %} diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 00000000..b6af1c84 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,619 @@ +{% extends "layouts/docs.html" %} + {% block content %} + +

{{ service_name }}

+ +

The {{ department_name }} {{ service_name }} supplies datasets via HTTPS without authentication.

+ + +

The source code for the {{ service_name }} is available in its GitHub + repository.

+ +

Getting started

+ +

Any tool that can make HTTPS requests can access the {{ service_name}}. Examples are curl, Postman, or the web browser you're + currently using.

+ +

For example {{ base_url }}/v1/datasets?format=json will + return a list of datasets.

+ +

Base URL

+

All requests to this API should be prefixed with the following URL.

+
{{ base_url }}
+ +

Versioning

+ +

Datasets are versioned according to a subset of the Semver 2.0 + specification. Each version is of the form X.Y.Z, where X is the major version, Y is the minor version, and Z + is the patch version. Each release of a dataset increments the version according to the following rules.

+ + + +

Reports

+ +

Datasets can contain reports. Reports are similar to tables, except that the data in reports is generated + from the tables in the dataset. Reports are available to satisfy common use cases for filtered or aggregated + views of the data in a dataset.

+ +

If a dataset is available as SQLite, reports are generated using SQL in the _reports table in the SQLite file.

+ +

Common parameters

+ +

Several URL parameters are applicable to multiple API endpoints.

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescription
dataset_idA human-readable identifier of a dataset, e.g. {{ dataset }} +
version_id +

A version identifier in the format vX.Y.Z, where X.Y.Z is the Semver 2.0 version of the + dataset, e.g. {{ version }}

+

or

+

A version in the format vX.Y. In this case, a HTTP 302 redirect is + returned to the URL requested, but with version_id equal to the latest + version of the dataset with major and minor components matching vX.Y +

+

or

+

A version in the format vX. In this case, a HTTP 302 redirect is + returned to the URL requested, but with version_id equal to the latest + version of the dataset with major component matching vX

+

or

+

The literal latest. In this case, a HTTP 302 redirect is returned to + the URL requested, but with version_id equal to the latest version of + the dataset

+
table_idA human-readable identifier of a table, e.g. {{ table_name }} +
report_idA human-readable identifier of a report, e.g. + {{ sample_dataset_with_report_report_name }}
+ +

API Endpoints

+ +

GET list of datasets

+

The list of all datasets available in the {{ service_name }} can be accessed using this endpoint.

+
GET /v1/datasets
+

Query string parameters

+ + + + + + + + + + + + + + + +
NameRequiredDescription
formatYesThe requested output format. In all cases, this must be json
+

Example

+
Request
+
curl --get {{ base_url }}/v1/datasets \
+  --data-urlencode "format=json"
+
Response
+
Status: 200 OK
+{
+  "datasets": [
+      {"id": "market-barriers"}, {"id": "uk-tariff-2021-01-01"}
+  ]
+}
+ +

GET list of versions of a dataset

+

The list of versions of each dataset can be accessed using this endpoint.

+
GET /v1/datasets/{dataset_id}/versions
+

Query string parameters

+ + + + + + + + + + + + + + + +
NameRequiredDescription
formatYesThe requested output format. In all cases, this must be json
+

Example

+
Request
+
curl --get {{ base_url }}/v1/datasets/{{ dataset }}/versions \
+  --data-urlencode "format=json"
+
Response
+
Status: 200 OK
+{
+  "versions": [
+      {"id": "{{ latest_version }}"}, {"id": "{{ version }}"}
+  ]
+}
+ +

GET list of tables in a version

+

The list of tables of each dataset version can be accessed using this endpoint.

+
GET /v1/datasets/{dataset_id}/versions/{version_id}/tables
+

Query string parameters

+ + + + + + + + + + + + + + + +
NameRequiredDescription
formatYesThe requested output format. In all cases, this must be json
+

Example

+
Request
+
curl --get {{ base_url }}/v1/datasets/{{ dataset }}/versions/{{ version }}/tables \
+  --data-urlencode "format=json"
+
Response
+
Status: 200 OK
+{
+  "tables": [
+      {"id": "commodities"},
+      {"id": "measures-as-defined"},
+      {"id": "measures-on-declarable-commodities"}
+  ]
+}
+ +

GET list of reports in a version

+

The list of reports of each dataset version can be accessed using this endpoint.

+
GET /v1/datasets/{dataset_id}/versions/{version_id}/reports
+

Query string parameters

+ + + + + + + + + + + + + + + +
NameRequiredDescription
formatYesThe requested output format. In all cases, this must be json
+

Example

+
Request
+
curl --get {{ base_url }}/v1/datasets/{{ sample_dataset_with_report }}/versions/{{ sample_dataset_with_report_version }}/reports \
+  --data-urlencode "format=json"
+
Response
+
Status: 200 OK
+{
+  "reports": [
+      {"id": "quotas-including-current-volumes"}
+  ]
+}
+ +

GET metadata of a version

+

The metadata of a dataset version can be accessed using this endpoint.

+
GET /v1/datasets/{dataset_id}/versions/{version_id}/metadata
+

Query string parameters

+ + + + + + + + + + + + + + + + + + + + +
NameRequiredDescription
formatYesThe requested output format. This must be csvw or html
downloadNoThe presence of this parameter results in a content-disposition header so that browsers attempt to download the metadata + rather than display it inline
+

Example requesting CSVW

+
Request
+
curl --get {{ base_url }}/v1/datasets/{{ dataset }}/versions/{{ version }}/metadata \
+  --data-urlencode "format=csvw"
+
Response (excerpt)
+
Status: 200 OK
+{
+"@context": [
+  "http://www.w3.org/ns/csvw",
+  {"dit": "http://data.api.trade.gov.uk/"}
+],
+"dc:title": "Tariffs to trade with the UK from 1 January 2021",
+...
+"tables": [{
+  "id": "commodities",
+  ...
+  "tableSchema": {
+    "columns": [{
+      "name": "id",
+      ...
+    }, ...]
+  }
+}, ...]
+}
+ +

GET data in a version

+

All of the data of a dataset version can be accessed using this endpoint

+
GET /v1/datasets/{dataset_id}/versions/{version_id}/data
+

Query string parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + +
NameRequiredDescription
formatYesThe requested output format. This must be sqlite, json, or ods
query-s3-selectNo +

A query using the S3 + Select query language, e.g. SELECT * FROM S3Object[*]

+

The response is a JSON object with the query results under the rows + key, i.e. {"rows": [...]}

+

Using query-s3-select requires that the format parameter be json.

+
downloadNoThe presence of this parameter results in a content-disposition header so that browsers attempt to download the data + rather than display it inline.
+

Range requests

+

If a query-s3-select is not specified, the range HTTP header can be passed to select a byte-range of the dataset. See HTTP Range Requests for more + details.

+

Example without a query

+
Request
+
curl --get {{ base_url }}/v1/datasets/{{ dataset }}/versions/{{ version }}/data \
+  --data-urlencode "format=json"
+
Response (excerpt)
+
Status: 200 OK
+{
+  "commodities": [
+      {"id": "1", "commodity__code": "0100000000", ...
+      ...
+  ],
+  ...
+}
+

Example with a query

+
Request
+
curl --get https://data.api.trade.gov.uk/v1/datasets/uk-tariff-2021-01-01/versions/v2.1.0/data \
+  --data-urlencode "format=json" \
+  --data-urlencode "query-s3-select=
+      SELECT
+          c.commodity__code, c.commodity__suffix, c.commodity__description
+      FROM
+          S3Object[*].commodities[*] c
+      WHERE
+          c.commodity__code = '0101210000'
+      LIMIT
+          1
+  "
+
Response
+
Status: 200 OK
+{
+  "rows":[
+    {"commodity__code": "0101210000", "commodity__suffix": "10", "commodity__description": "Horses"}
+  ]
+}
+ +

GET data in a table

+

The data of single table in a dataset version can be accessed using this endpoint.

+
GET /v1/datasets/{dataset_id}/versions/{version_id}/tables/{table_id}/data
+

Query string parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameRequiredDescription
formatYesThe requested output format. This must be csv + or ods
query-s3-selectNo +

A query using the S3 + Select query language, e.g. SELECT * FROM S3Object

+
query-simpleNo +

Enables a "simple" query mode to specify columns to retrieve, and filter rows using exact matching. +

+

In simple mode, the value of each _columns parameter is a + single column to include in the output. This parameter can be passed multiple times to include + multiple columns.

+

Filtering on rows can then be performed by passing key value pairs column=value. The output includes only those rows where column column equals value.

+
downloadNoThe presence of this parameter results in a content-disposition header so that browsers attempt to download the data + rather than display it inline.
+

Range requests

+

If query-s3-select and query-simple are + not specified, the range HTTP header can be passed to select a + byte-range of the table. See HTTP + Range Requests for more details.

+

Example without a query

+
Request
+
curl --get {{ base_url }}/v1/datasets/{{ dataset }}/versions/{{ version }}/tables/{{ table_name }}/data \
+  --data-urlencode "format=csv"
+
Response
+
Status: 200 OK
+"id","commodity__sid","commodity__code","commodity__suffix","commodity__description","commodity__validity_start","commodity__validity_end","parent__sid","parent__code","parent__suffix"
+"1","27623","0100000000","80","LIVE ANIMALS","1971-12-31","#NA","#NA","#NA","#NA"
+"2","27624","0101000000","80","Live horses, asses, mules and hinnies","1972-01-01","#NA","27623","0100000000","80"
+"3","93797","0101210000","10","Horses","2012-01-01","#NA","27624","0101000000","80"
+
+ +

Example with an S3 Select query

+
Request
+
curl --get {{ base_url }}/v1/datasets/{{ dataset }}/versions/{{ version }}/tables/{{ table_name }}/data \
+  --data-urlencode "format=csv" \
+  --data-urlencode "query-s3-select=
+      SELECT
+          c.commodity__code, c.commodity__suffix, c.commodity__description
+      FROM
+          S3Object c
+      WHERE
+          c.commodity__code = '0101210000'
+      LIMIT
+          1
+  "
+ +
Response
+
Status: 200 OK
+0101210000,10,Horses
+
+ +

Example with a simple query

+
Request
+
curl --get {{ base_url }}/v1/datasets/{{ dataset }}/versions/{{ version }}/tables/{{ table_name }}/data \
+  --data-urlencode "format=csv" \
+  --data-urlencode "query-simple" \
+  --data-urlencode "commodity__code=0101210000" \
+  --data-urlencode "_columns=commodity__code" \
+  --data-urlencode "_columns=commodity__suffix" \
+  --data-urlencode "_columns=commodity__description"
+
+ +
Response
+
Status: 200 OK
+commodity__code,commodity__suffix,commodity__description
+0101210000,10,Horses
+0101210000,80,Pure-bred breeding animals
+
+ +

GET data in a report

+

The data of a single report in a dataset version can be accessed using this endpoint.

+
GET /v1/datasets/{dataset_id}/versions/{version_id}/reports/{report_id}/data
+

Query string parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameRequiredDescription
formatYesThe requested output format. This must be csv + or ods
query-s3-selectNo +

A query using the S3 + Select query language, e.g. SELECT * FROM S3Object

+
query-simpleNo +

Enables a "simple" query mode to specify columns to retrieve, and filter rows using exact matching. +

+

In simple mode, the value of each _columns parameter is a + single column to include in the output. This parameter can be passed multiple times to include + multiple columns.

+

Filtering on rows can then be performed by passing key value pairs column=value. The output includes only those rows where column column equals value.

+
downloadNoThe presence of this parameter results in a content-disposition header so that browsers attempt to download the data + rather than display it inline.
+

Range requests

+

If query-s3-select and query-simple are + not specified, the range HTTP header can be passed to select a + byte-range of the report. See HTTP + Range Requests for more details.

+

Example without a query

+
Request
+
curl --get {{ base_url }}/v1/datasets/{{ sample_dataset_with_report }}/versions/{{ sample_dataset_with_report_version }}/reports/{{ sample_dataset_with_report_report_name }}/data \
+  --data-urlencode "format=csv"
+
Response (excerpt)
+
Status: 200 OK
+"quota_definition__sid","quota__order_number","quota__geographical_areas","quota__headings","quota__commodities","quota__measurement_unit","quota__monetary_unit","quota_definition__description","quota_definition__validity_start_date","quota_definition__validity_end_date","quota_definition__suspension_periods","quota_definition__blocking_periods","quota_definition__status","quota_definition__last_allocation_date","quota_definition__initial_volume","quota_definition__balance","quota_definition__fill_rate"
+20815,50006,"ERGA OMNES","0302 – Fish, fresh or chilled, excluding fish fillets and other fish meat of heading|0304|0303 – Fish, frozen, excluding fish fillets and other fish meat of heading 0304|0304 – Fish fillets and other fish meat (whether or not minced), fresh, chilled or frozen","0302410000|0303510000|0304595000|0304599010|0304992300","Kilogram (kg)","#NA","#NA","2021-01-01","2021-02-14","#NA","#NA","Closed","2021-01-28",2022900,2022900.0,0.0
+20814,50006,"ERGA OMNES","0302 – Fish, fresh or chilled, excluding fish fillets and other fish meat of heading|0304|0303 – Fish, frozen, excluding fish fillets and other fish meat of heading 0304|0304 – Fish fillets and other fish meat (whether or not minced), fresh, chilled or frozen","0302410000|0303510000|0304595000|0304599010|0304992300","Kilogram (kg)","#NA","#NA","2021-06-16","2022-02-14","#NA","#NA","Open","#NA",2112000,2112000.0,0.0
+
+ +

Example with an S3 Select query

+
Request
+
curl --get {{ base_url }}/v1/datasets/{{ sample_dataset_with_report }}/versions/{{ sample_dataset_with_report_version }}/reports/{{ sample_dataset_with_report_report_name }}/data \
+  --data-urlencode "format=csv" \
+  --data-urlencode "query-s3-select=
+      SELECT
+          q.quota__order_number, q.quota_definition__validity_start_date, q.quota_definition__status, q.quota_definition__initial_volume, q.quota_definition__balance
+      FROM
+          S3Object q
+      WHERE
+          q.quota__commodities LIKE '%0203195900%'
+  "
+ +
Response
+
Status: 200 OK
+50123,2021-01-01,Exhausted,2000,0.0
+50123,2021-07-01,Open,1349000,1349000.0
+51921,2021-01-01,Open,1632000,1632000.0
+51944,2021-01-01,Critical,167000,147000.0
+57220,2021-01-01,Open,494000,494000.0
+59282,2021-01-01,Open,4838000,4838000.0
+
+ +

Example with a simple query

+
Request
+
curl --get {{ base_url }}/v1/datasets/{{ sample_dataset_with_report }}/versions/{{ sample_dataset_with_report_version }}/reports/{{ sample_dataset_with_report_report_name }}/data \
+  --data-urlencode "format=csv" \
+  --data-urlencode "query-simple" \
+  --data-urlencode "quota__order_number=50123" \
+  --data-urlencode "_columns=quota__order_number" \
+  --data-urlencode "_columns=quota_definition__validity_start_date" \
+  --data-urlencode "_columns=quota_definition__status" \
+  --data-urlencode "_columns=quota_definition__initial_volume" \
+  --data-urlencode "_columns=quota_definition__balance"
+
+ +
Response
+
Status: 200 OK
+quota__order_number,quota_definition__validity_start_date,quota_definition__status,quota_definition__initial_volume,quota_definition__balance
+50123,2021-01-01,Exhausted,2000,0.0
+50123,2021-07-01,Open,1349000,1349000.0
+
+ +

Support

+ +

For help with the {{ service_name }} please create an issue on its GitHub issues page.

+ +

Security

+ +

To report a security vulnerability please contact us at {{ + security_email }}.

+ +

Accessibility

+ +

Please find the accessibility statement.

+ {% endblock %} + diff --git a/templates/base.html b/templates/layouts/base.html similarity index 100% rename from templates/base.html rename to templates/layouts/base.html diff --git a/templates/layouts/docs.html b/templates/layouts/docs.html new file mode 100644 index 00000000..c6671537 --- /dev/null +++ b/templates/layouts/docs.html @@ -0,0 +1,45 @@ + + + + + + + + {{ service_name }} - {{ department_name }} + + + + + + + + + + + + + + + + +
+ {% include "partials/header.html" %} +
+ +
+
+ {% include "partials/navigation.html" %} +
+
+ {% block content %}{% endblock %} +
+ {% include "partials/footer.html" %} +
+
+
+ + + diff --git a/templates/layouts/page.html b/templates/layouts/page.html new file mode 100644 index 00000000..62c43781 --- /dev/null +++ b/templates/layouts/page.html @@ -0,0 +1,32 @@ + + + + + + + {{ service_name }} - {{ department_name }} + + + + + + + + + + + + + + + + + {% include "partials/header.html" %} +
+ {% block content %}{% endblock %} +
+ {% include "partials/footer.html" %} + + + diff --git a/templates/metadata.html b/templates/metadata.html index 37a12b67..52f3dbbd 100644 --- a/templates/metadata.html +++ b/templates/metadata.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "layouts/base.html" %} {% block title %}{{ csvw['dc:title'] }} - {{ version }}{% endblock %} diff --git a/templates/pages/accessibility_statement.html b/templates/pages/accessibility_statement.html new file mode 100644 index 00000000..9c5df97d --- /dev/null +++ b/templates/pages/accessibility_statement.html @@ -0,0 +1,22 @@ +{% extends "layouts/page.html" %} + {% block content %} +

Accessibility Statement

+

+ The Department for Business and Trade digital team is committed to making sure our online services are accessible to all users and comply with level AA of the Web Content Accessibility Guidelines – WCAG 2.1, in line with The Public Sector Bodies (Websites and Mobile Applications) (No. 2) Accessibility Regulations 2018. +

+

+ In order to help us achieve and maintain our objective, we have commissioned The Digital Accessibility Centre (DAC) to carry out WCAG 2.1 AA level technical compliance audits that also include extensive manual testing. +

+

+ We anticipate the outcome of all tests to be complete by 16th December 2023. +

+

What to do if you cannot access parts of this website

+

+ If you need information on this website in a different format, email Kathy.Gribbin@trade.gov.uk. If you have a problem with accessing any of the pages on this site you can contact us at data-workspace@uktrade.zendesk.com. We’ll get back to you within 5 working days. +

+

Reporting accessibility problems with this website

+

+ We’re always looking to improve the accessibility of this website. + If you find any problems or think we’re not meeting the requirements of the accessibility regulations,
please tell us by contacting data-workspace@uktrade.zendesk.com. +

+{% endblock %} diff --git a/templates/partials/footer.html b/templates/partials/footer.html new file mode 100644 index 00000000..0e2743f4 --- /dev/null +++ b/templates/partials/footer.html @@ -0,0 +1,22 @@ + diff --git a/templates/partials/header.html b/templates/partials/header.html new file mode 100644 index 00000000..232513b0 --- /dev/null +++ b/templates/partials/header.html @@ -0,0 +1,22 @@ +
+ Skip to main content + +
diff --git a/templates/partials/navigation.html b/templates/partials/navigation.html new file mode 100644 index 00000000..b0480b82 --- /dev/null +++ b/templates/partials/navigation.html @@ -0,0 +1,68 @@ +
+ +