source("R/setup.R")$value
if (!sc_key_exists()) knitr::opts_chunk$set(eval = FALSE)
Apart form [/table
] and [/schema
], there is also support for the simple
endpoints [/info
] and [/rate_limit
].
The [/info
] endpoint gives and overview about the available languages on the server.
sc_info()
data.frame(locale = c("de", "en"), displayName = c("Deutsch", "English")) %>% `class<-`(c("tbl", "data.frame"))
The [/rate_limit
] endpoint shows the number of calls to the [/table
]
endpoint that are remaining.
sc_rate_limit_table()
rl <- sc_example("population_timeseries.json") %>% sc_table() %>% sc_rate_limits() rl$table
In this case, we see that 8 out of the 100 requests per hour have been used up
and 92 are still available.
The rate limit will be reset once per hour.
In this case this will be at 2022-08-30 13:53:55
.
The entry under reset should always be less than one
hour after the request to the [/rate_limit
] endpoint was sent.
Schema requests are currently limited to 10000 requests per hour.
The number of remaining requests can be obtained via sc_rate_limit_schema()
.
Rate limits are be returned in the same format as in sc_rate_limit_table()
.
sc_rate_limit_schema()
rl$schema
All responses from the STATcube API contain rate limit information (including remaining requests) in the response headers^[Responses for unauthorized requests (response status 401) are an exception].
So instead of using the /rate_limit*
endpoints shown above, it is also possible to use responses from other endpoints and extract rate limit information from their headers.
The function sc_rate_limits()
does just that.
Any return value from sc_table()
, sc_table_saved()
and sc_table_custom()
can be passed to sc_rate_limits()
and the rate limits will be extracted from the response headers.
sc_example("population_timeseries.json") %>% sc_table() %>% sc_rate_limits()
Note that the function gives rate limits for /schama
and /table
even tough only the /table
endpoint was used.
The function also works with return values from sc_schema()
and friends.
sc_schema_catalogue() %>% sc_rate_limits()
~~STATcube uses caching for the [/table
] endpoint by default. If the same
request to sc_table()
is sent several times, this will not count
towards the rate-limit (100 requests per hour).~~
Server-Side caching of [/table
] responses is currently disabled due to security reasons.
Therefore, all requests against the [/table
] endpoint count towards the rate-limit.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.