ERA5 data is available through the Climate Data Store (CDS). However some ERA5 datasets do not appear in CDS but are accessible through CDS API (for example, ERA5 wave spectra data, ERA5 model level data and ERA5 monthly means archived at ECMWF's MARS archive). The ERA5 Wave data is currently archived in the ECMWF MARS tape library. To retrieve this data, you will need to use MARS Keywords in your CDS API request. Details are available from How to download ERA5 (Section 3  Step C: Download ERA5 data NOT listed in CDS through CDS API).
Wave data can be downloaded using the same mechanisms as atmospheric data. Please see How to download data via the ECMWF WebAPI
For wave spectra you need to specify the additional parameters 'direction' and 'frequency'.
If you want to download the data in NetCDF format, please add the 'format' and 'grid' parameters:

To decode wave spectra in GRIB format we recommend ecCodes. Wave spectra are encoded in a specific way that other tools might not decode correctly.
In GRIB, the parameter is called 2d wave spectra (single) because in GRIB, the data are stored as a single global field per each spectral bin (a given frequency and direction), but in NetCDF, the fields are nicely recombined to produce a 2d matrix representing the discretized spectra at each grid point.
The wave spectra are encoded in GRIB using a local table specific to ECMWF. Because of this, the conversion of the meta data containing the information about the frequencies and the directions are not properly converted from GRIB to NetCDF format. So rather than having the actual values of the frequencies and directions, values show index numbers (1,1) : first frequency, first direction, (1,2) first frequency, second direction, etc ....
For ERA, because there are a total of 24 directions, the direction increment is 15 degrees with the first direction given by half the increment, namely 7.5 degree, where direction 0. means going towards the north and 90 towards the east (Oceanographic convention), or more precisely, this should be expressed in gradient since the spectra are in m^2 /(Hz radian)
The first frequency is 0.03453 Hz and the following ones are : f(n) = f(n1)*1.1, n=2,30
Also note that it is NOT the spectral density that is encoded but rather log10 of it, so to recover the spectral density, expressed in m^2 /(radian Hz), one has to take the power 10 (10^) of the NON missing decoded values. Missing data are for all land points, but also, as part of the GRIB compression, all small values below a certain threshold have been discarded and so those missing spectral values are essentially 0. m^2 /(gradient Hz).
The NetCDF wave spectra file will have the dimensions longitude, latitude, direction, frequency and time.
However, the direction and frequency bins are simply given as 1 to 24 and 1 to 30, respectively.
The direction bins start at 7.5 degree and increase by 15 degrees until 352.5, with 90 degree being towards the east (Oceanographic convention).
The frequency bins are nonlinearly spaced. The first bin is 0.03453 Hz and the following bins are: f(n) = f(n1)*1.1; n=2,30. The data provided is the log10 of spectra density. To obtain the spectral density one has to take to the power 10 (10 ** data). This will give the units 2D wave spectra as m**2 s radian**1 . Very small values are discarded and set as missing values. These are essentially 0 m**2 s radian**1.
This recoding can be done with the Python xarray package, for example:
import xarray as xr import numpy as np da = xr.open_dataarray('2d_spectra_201601.nc') da = da.assign_coords(direction=np.arange(7.5, 352.5 + 15, 15)) da = da.assign_coords(frequency=np.full(30, 0.03453) * (1.1 ** np.arange(0, 30))) da = 10 ** da da = da.fillna(0) da.to_netcdf(path='2d_spectra_201601_recoded.nc') 
Once decoded, the units of 2D wave spectra are m^{2} s radian^{1}
Additional information about wave model data can be found in JeanRaymond Bidlot (2016), Ocean wave model output parameters (see ECMWF Model Documentation).