MyNixOS website logo
Description

Client for the 'ONS' API.

Client for the 'Office of National Statistics' ('ONS') API <https://api.beta.ons.gov.uk/v1>.

onsr

R-CMD-check Lifecycle:experimental CRANstatus

NOTE: This API is currently in Beta and still being developed. Please be aware that as a result of this there may occasionally be breaking changes.

The goal of onsr is to to provide a client for the ‘Office of National Statistics’ (‘ONS’) API https://api.beta.ons.gov.uk/v1.

Installation

# Install release version from CRAN
install.packages("onsr")

You can install the development version of onsr from GitHub.

# install.packages("devtools")
devtools::install_github("kvasilopoulos/onsr")

If you encounter a clear bug, please file a reproducible example on GitHub.

Example

This is a basic example which shows you how to download data with onsr.

library(onsr)

ons_get(id = "ageing-population-estimates")
#> # A tibble: 18,960 x 12
#>     V4_1 `Data Marking` `calendar-years`  Time `administrative-g~ Geography  sex   Sex  
#>    <dbl> <chr>                     <dbl> <dbl> <chr>              <chr>      <chr> <chr>
#>  1    NA .                          2019  2019 E08000008          Tameside   fema~ Fema~
#>  2    NA .                          2019  2019 E12000009          South West fema~ Fema~
#>  3 83288 <NA>                       2019  2019 E08000006          Salford    fema~ Fema~
#>  4    NA .                          2019  2019 W92000004          Wales      male  Male 
#>  5    NA .                          2019  2019 E07000166          Richmonds~ all   All  
#>  6 55635 <NA>                       2019  2019 E06000034          Thurrock   fema~ Fema~
#>  7 14437 <NA>                       2019  2019 E07000108          Dover      fema~ Fema~
#>  8 10736 <NA>                       2019  2019 E07000131          Harborough fema~ Fema~
#>  9 12646 <NA>                       2019  2019 E07000106          Canterbury fema~ Fema~
#> 10  9450 <NA>                       2019  2019 E07000237          Worcester  fema~ Fema~
#> # ... with 18,950 more rows, and 4 more variables: age-groups <chr>, AgeGroups <chr>,
#> #   unit-of-measure <chr>, UnitOfMeasure <chr>

# All the available id names
ons_ids()
#>  [1] "wellbeing-quarterly"                          
#>  [2] "wellbeing-local-authority"                    
#>  [3] "weekly-deaths-region"                         
#>  [4] "weekly-deaths-local-authority"                
#>  [5] "weekly-deaths-health-board"                   
#>  [6] "weekly-deaths-age-sex"                        
#>  [7] "uk-spending-on-cards"                         
#>  [8] "traffic-camera-activity"                      
#>  [9] "trade"                                        
#> [10] "tax-benefits-statistics"                      
#> [11] "suicides-in-the-uk"                           
#> [12] "regional-gdp-by-year"                         
#> [13] "regional-gdp-by-quarter"                      
#> [14] "projections-older-people-sex-ratios"          
#> [15] "projections-older-people-in-single-households"
#> [16] "output-in-the-construction-industry"          
#> [17] "online-job-advert-estimates"                  
#> [18] "older-people-sex-ratios"                      
#> [19] "older-people-net-internal-migration"          
#> [20] "older-people-economic-activity"               
#> [21] "mid-year-pop-est"                             
#> [22] "life-expectancy-by-local-authority"           
#> [23] "labour-market"                                
#> [24] "index-private-housing-rental-prices"          
#> [25] "house-prices-local-authority"                 
#> [26] "health-accounts"                              
#> [27] "gva-by-industry-by-local-authority"           
#> [28] "generational-income"                          
#> [29] "gdp-to-four-decimal-places"                   
#> [30] "gdp-by-local-authority"                       
#> [31] "faster-indicators-shipping-data"              
#> [32] "cpih01"                                       
#> [33] "childrens-wellbeing"                          
#> [34] "ashe-tables-9-and-10"                         
#> [35] "ashe-tables-7-and-8"                          
#> [36] "ashe-tables-3"                                
#> [37] "ashe-tables-27-and-28"                        
#> [38] "ashe-tables-26"                               
#> [39] "ashe-tables-25"                               
#> [40] "ashe-tables-20"                               
#> [41] "ashe-tables-11-and-12"                        
#> [42] "ashe-table-5"                                 
#> [43] "ageing-population-projections"                
#> [44] "ageing-population-estimates"

Rate limiting

The ONS API applies rate limiting to ensure a high quality service is delivered to all users and to protect client applications from unexpected loops.

The following rate limits have been implemented:

  • 120 requests per 10 seconds

  • 200 requests per 1 minute

If you exceed these limits the API will return a 429 Too Many Requests HTTP status code and a Retry-After header containing the number of seconds until you may try your request again.

Metadata

Version

1.0.2

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows