or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

current-data-streams.mdentry-points.mdhistorical-data-streams.mdindex.mdmain-source.mdstate-historical-streams.md

current-data-streams.mddocs/

0

# Current Data Streams

1

2

Full-refresh streams providing current COVID-19 statistics snapshots. These streams deliver the most recent available data for Germany overall, individual states, and age group breakdowns without historical tracking.

3

4

## Capabilities

5

6

### Germany Overall Statistics

7

8

Current COVID-19 statistics for Germany as a whole.

9

10

```python { .api }

11

class Germany(RkiCovidStream):

12

"""

13

Current COVID-19 statistics for Germany overall.

14

15

API Endpoint: https://api.corona-zahlen.org/germany/

16

Sync Mode: Full refresh

17

Primary Key: None

18

19

Returns current national-level statistics including cases, deaths,

20

recovered, incidence rates, and other epidemiological metrics.

21

"""

22

23

primary_key = None

24

25

def path(self, stream_state=None, stream_slice=None, next_page_token=None) -> str:

26

"""Returns API path: 'germany/'"""

27

```

28

29

### Germany States Statistics

30

31

Current COVID-19 statistics for all German states (Bundesländer).

32

33

```python { .api }

34

class GermanyStates(RkiCovidStream):

35

"""

36

Current COVID-19 statistics for all German states.

37

38

API Endpoint: https://api.corona-zahlen.org/states/

39

Sync Mode: Full refresh

40

Primary Key: None

41

42

Returns current statistics for each German state including

43

state name, abbreviation, and all COVID-19 metrics.

44

"""

45

46

primary_key = None

47

48

def path(self, stream_state=None, stream_slice=None, next_page_token=None) -> str:

49

"""Returns API path: 'states/'"""

50

51

def parse_response(self, response, **kwargs):

52

"""

53

Parses nested state data from API response.

54

55

Extracts individual state records from response.json().get("data")

56

where each state is keyed by abbreviation.

57

"""

58

```

59

60

### Germany Age Groups Statistics

61

62

Current COVID-19 statistics broken down by age groups for Germany.

63

64

```python { .api }

65

class GermanyAgeGroups(RkiCovidStream):

66

"""

67

Current COVID-19 statistics by age groups for Germany.

68

69

API Endpoint: https://api.corona-zahlen.org/germany/age-groups

70

Sync Mode: Full refresh

71

Primary Key: None

72

73

Returns current age-stratified statistics for epidemiological

74

analysis by demographic groups.

75

"""

76

77

primary_key = None

78

79

def path(self, stream_state=None, stream_slice=None, next_page_token=None) -> str:

80

"""Returns API path: 'germany/age-groups'"""

81

82

def parse_response(self, response, **kwargs):

83

"""

84

Extracts age group data from API response.

85

86

Returns response.json().get("data") containing age group statistics.

87

"""

88

```

89

90

### Germany States Age Groups Statistics

91

92

Current COVID-19 statistics by age groups for each German state.

93

94

```python { .api }

95

class GermanyStatesAgeGroups(RkiCovidStream):

96

"""

97

Current COVID-19 statistics by age groups for all German states.

98

99

API Endpoint: https://api.corona-zahlen.org/states/age-groups

100

Sync Mode: Full refresh

101

Primary Key: None

102

103

Returns age-stratified statistics for each state, combining

104

geographical and demographic breakdowns.

105

"""

106

107

primary_key = None

108

109

def path(self, stream_state=None, stream_slice=None, next_page_token=None) -> str:

110

"""Returns API path: 'states/age-groups'"""

111

112

def parse_response(self, response, **kwargs):

113

"""

114

Parses nested states and age groups data.

115

116

Flattens the nested structure where each state contains

117

multiple age group records, adding state abbreviation

118

to each age group record.

119

"""

120

```

121

122

## Base Stream Class

123

124

All current data streams inherit from the base RkiCovidStream class.

125

126

```python { .api }

127

class RkiCovidStream(HttpStream, ABC):

128

"""

129

Base class for full-refresh RKI COVID streams.

130

131

Provides common functionality including:

132

- Base URL: https://api.corona-zahlen.org/

133

- No pagination (single page responses)

134

- Standard JSON parsing

135

- Common request parameter handling

136

"""

137

138

url_base = "https://api.corona-zahlen.org/"

139

140

def next_page_token(self, response) -> Optional[Mapping[str, Any]]:

141

"""No pagination - returns None"""

142

143

def request_params(self, stream_state=None, stream_slice=None, next_page_token=None):

144

"""Returns empty dict - no additional parameters needed"""

145

146

def parse_response(self, response, **kwargs):

147

"""

148

Default response parsing.

149

150

Returns:

151

Single JSON response as iterable containing one record.

152

"""

153

```

154

155

## Usage Examples

156

157

### Accessing Current Data

158

159

```python

160

from source_rki_covid import SourceRkiCovid

161

162

source = SourceRkiCovid()

163

config = {"start_date": "2023-01-01"}

164

165

# Get all streams

166

streams = source.streams(config)

167

168

# Filter for current data streams

169

current_streams = [

170

stream for stream in streams

171

if stream.__class__.__name__ in [

172

'Germany', 'GermanyStates', 'GermanyAgeGroups', 'GermanyStatesAgeGroups'

173

]

174

]

175

176

print(f"Current data streams: {len(current_streams)}") # 4 streams

177

```

178

179

### Reading Current Statistics

180

181

```python

182

# Example with Germany stream

183

germany_stream = Germany()

184

185

# Read current records (typically one record with current stats)

186

for record in germany_stream.read_records():

187

print(f"Current Germany statistics: {record}")

188

189

# Example with States stream

190

states_stream = GermanyStates()

191

192

# Read current records for all states

193

for record in states_stream.read_records():

194

print(f"State: {record.get('name')}, Cases: {record.get('cases')}")

195

```

196

197

## Data Structure

198

199

Current data streams return comprehensive COVID-19 statistics including:

200

201

- **Cases**: Total confirmed cases and daily new cases

202

- **Deaths**: Total deaths and daily new deaths

203

- **Recovered**: Total recovered cases and daily new recovered

204

- **Incidence**: 7-day incidence rates per 100,000 population

205

- **Hospitalization**: Current hospitalization metrics

206

- **Metadata**: Last update timestamps, data sources, geographic identifiers

207

208

State-level streams additionally include:

209

- **State Name**: Full German state name

210

- **Abbreviation**: Two-letter state code

211

- **Population**: State population figures for rate calculations