ICOS Data Usage Statistics: the API

The API

Every endpoint of the download statistics lives under /stats/api/ and answers JSON, by GET with a query string or by POST with a JSON object carrying the same names; OPTIONS answers the CORS preflight. The same table, as a machine-readable document: openapi.json, with the keys below as the parameters of every endpoint; browse and try them in Swagger UI.

MethodPathAnswers
GET, POST/stats/api/downloadsByCountrydownloads per download country under the filter
GET, POST/stats/api/dlfromevery download country ever seen, with its count
GET, POST/stats/api/downloadsPerWeekdownloads per ISO week under the filter
GET, POST/stats/api/downloadsPerMonthdownloads per month under the filter
GET, POST/stats/api/downloadsPerYeardownloads per year under the filter
GET, POST/stats/api/downloadStatsthe most downloaded objects under the filter, paged (page, pagesize)
GET, POST/stats/api/specificationsevery data type ever seen, with its count
GET, POST/stats/api/contributorsevery contributor ever seen, with its count
GET, POST/stats/api/submittersevery submitter ever seen, with its count
GET, POST/stats/api/stationsevery station ever seen, with its count
GET, POST/stats/api/customDownloadsPerYearCountrydownloads per year and download country, the filter ignored
GET, POST/stats/api/downloadCountthe downloads of one object (hashId)
GET, POST/stats/api/lastDownloadsthe most recent downloads (limit, itemType)
GET/stats/api/openapi.jsonthis route table as an OpenAPI 3.0 document
GET/stats/api/swaggerSwagger UI over openapi.json: browse the endpoints and try them

The query

A list key takes repeated keys (specs=A&specs=B), a comma list (specs=A,B) or a JSON array literal (specs=%5B%22A%22%5D); in a POST body the same names carry JSON arrays. Every key is optional; an endpoint ignores the keys it has no use for. A value that cannot be read is answered 400 with the key named. Answers to the filtered endpoints are cached for ten minutes.

KeyTakesFor
specsdata type URIsevery endpoint
stationsstation URIsevery endpoint
contributorscontributor URIs (people and organisations)every endpoint
submitterssubmitter URIsevery endpoint
dlfromdownload countries, ISO 3166-1 alpha-2 codesevery endpoint
originStationsURIs of the stations the data originates fromevery endpoint
dlStartfrom this instant or day on, ISO 8601, UTCevery endpoint
dlEndup to this instant or dayevery endpoint
includeGrayDltrue to count the gray-listed downloads too (also includeGray)every endpoint
hashIdone data object, by its hash id; downloadCount needs itevery endpoint
pagethe page, from 1 (also pageOpt)downloadStats
pagesizeobjects a page, 1 to 100000 (also pagesizeOpt)downloadStats
limithow many, 1 to 100000lastDownloads
itemTypedata, collection or documentlastDownloads
projectsproject labels, translated into specsthe pages and the CSV
levelsdata levels 0 to 3, translated into specsthe pages and the CSV
origindata-origin countries, translated into originStationsthe pages and the CSV
domainsatm, eco, oce or other, translated into specsthe pages and the CSV
versionslibrary versions (the Python library view)the pages and the CSV
librariesicoscp or icoscp_core (the Python library view)the pages and the CSV
storeszarr stores (the Zarr view)the pages and the CSV
groupszarr groups (the Zarr view)the pages and the CSV
variableszarr variables (the Zarr view)the pages and the CSV
unitweek, month or year: the step of the seriesthe pages and the CSV

Examples

GET /stats/api/downloadsPerYear?dlfrom=SE
GET /stats/api/downloadsByCountry?specs=http://meta.icos-cp.eu/resources/cpmeta/atcCo2L2DataObject&dlStart=2024-01-01
GET /stats/api/downloadCount?hashId=0iQnqctEYJ-jM0ERHkXmVUO8
POST /stats/api/downloadStats
Content-Type: application/json

{"dlfrom":["SE","DE"],"dlStart":"2024-01-01","pagesizeOpt":10}

GET /stats/csv?unit=month&dlfrom=SE

The pages

The same statistics as pages, every filter in the URL under the keys above; the CSV routes answer the series of the page.

MethodPathAnswers
GET/stats/the Downloads page
GET/stats/object/one data object: its downloads
GET/stats/csvthe downloads series as CSV
GET/stats/pylibthe Python library page
GET/stats/pylib/object/one data object: its library downloads
GET/stats/pylib/csvthe library series as CSV
GET/stats/zarrthe Zarr page
GET/stats/zarr/object/one dataset (store/group): its transfers
GET/stats/zarr/csvthe zarr series as CSV
GET/stats/previewsthe Previews page
GET/stats/docsthis API and these pages, documented
GET/healthzok after a round trip to the database
GET/versionthe build stamp