@@ -118,6 +118,7 @@ export function loadDataSet(
118118 fixedParams : Record < string , unknown > ,
119119 userParams : Record < string , unknown > ,
120120 columns : string [ ] ,
121+ api_key = '' ,
121122 columnRenamings : Record < string , string > = { } ,
122123) : Promise < DataGroup | null > {
123124 const duplicates = get ( expandedDataGroups ) . filter ( ( d ) => d . title == title ) ;
@@ -131,7 +132,11 @@ export function loadDataSet(
131132 )
132133 . then ( ( ) => null ) ;
133134 }
134- const url = new URL ( ENDPOINT + `/${ endpoint } /` ) ;
135+ let url_string = ENDPOINT + `/${ endpoint } /` ;
136+ if ( api_key !== '' ) {
137+ url_string += `?api_key=${ api_key } ` ;
138+ }
139+ const url = new URL ( url_string ) ;
135140 const params = cleanParams ( userParams ) ;
136141 Object . entries ( fixedParams ) . forEach ( ( [ key , value ] ) => {
137142 url . searchParams . set ( key , String ( value ) ) ;
@@ -168,10 +173,14 @@ export function loadDataSet(
168173 } ) ;
169174}
170175
171- export function fetchCOVIDcastMeta ( ) : Promise <
172- { geo_type : string ; signal : string ; data_source : string ; time_type ?: string } [ ]
173- > {
174- const url = new URL ( ENDPOINT + `/covidcast_meta/` ) ;
176+ export function fetchCOVIDcastMeta (
177+ api_key : string ,
178+ ) : Promise < { geo_type : string ; signal : string ; data_source : string ; time_type ?: string } [ ] > {
179+ let url_string = ENDPOINT + `/covidcast_meta/` ;
180+ if ( api_key !== '' ) {
181+ url_string += `?api_key=${ api_key } ` ;
182+ }
183+ const url = new URL ( url_string ) ;
175184 url . searchParams . set ( 'format' , 'json' ) ;
176185 return fetchImpl < { geo_type : string ; signal : string ; data_source : string ; time_type ?: string } [ ] > ( url ) . catch (
177186 ( error ) => {
@@ -190,8 +199,9 @@ export function importCDC({ locations, auth }: { locations: string; auth?: strin
190199 {
191200 epiweeks : epiRange ( firstEpiWeek . cdc , currentEpiWeek ) ,
192201 } ,
193- { auth , locations } ,
202+ { locations } ,
194203 [ 'total' , 'num1' , 'num2' , 'num3' , 'num4' , 'num5' , 'num6' , 'num7' , 'num8' ] ,
204+ auth ,
195205 ) ;
196206}
197207
@@ -201,12 +211,14 @@ export function importCOVIDcast({
201211 geo_value,
202212 signal,
203213 time_type = 'day' ,
214+ api_key,
204215} : {
205216 data_source : string ;
206217 signal : string ;
207218 time_type ?: string ;
208219 geo_type : string ;
209220 geo_value : string ;
221+ api_key : string ;
210222} ) : Promise < DataGroup | null > {
211223 const title = `[API] COVIDcast: ${ data_source } :${ signal } (${ geo_type } :${ geo_value } )` ;
212224 return loadDataSet (
@@ -221,6 +233,7 @@ export function importCOVIDcast({
221233 } ,
222234 { data_source, signal, time_type, geo_type, geo_value } ,
223235 [ 'value' , 'stderr' , 'sample_size' ] ,
236+ api_key ,
224237 ) ;
225238}
226239
@@ -343,7 +356,7 @@ export function importFluView({
343356 {
344357 epiweeks : epiRange ( firstEpiWeek . fluview , currentEpiWeek ) ,
345358 } ,
346- { regions, issues, lag, auth } ,
359+ { regions, issues, lag } ,
347360 [
348361 'wili' ,
349362 'ili' ,
@@ -357,6 +370,7 @@ export function importFluView({
357370 'num_age_4' ,
358371 'num_age_5' ,
359372 ] ,
373+ auth ,
360374 {
361375 wili : '%wILI' ,
362376 ili : '%ILI' ,
@@ -395,8 +409,9 @@ export function importGHT({
395409 {
396410 epiweeks : epiRange ( firstEpiWeek . ght , currentEpiWeek ) ,
397411 } ,
398- { auth , locations, query } ,
412+ { locations, query } ,
399413 [ 'value' ] ,
414+ auth ,
400415 ) ;
401416}
402417
@@ -456,8 +471,9 @@ export function importQuidel({ auth, locations }: { auth: string; locations: str
456471 {
457472 epiweeks : epiRange ( firstEpiWeek . quidel , currentEpiWeek ) ,
458473 } ,
459- { auth , locations } ,
474+ { locations } ,
460475 [ 'value' ] ,
476+ auth ,
461477 ) ;
462478}
463479export function importSensors ( {
@@ -478,8 +494,9 @@ export function importSensors({
478494 {
479495 epiweeks : epiRange ( firstEpiWeek . sensors , currentEpiWeek ) ,
480496 } ,
481- { auth , names, locations } ,
497+ { names, locations } ,
482498 [ 'value' ] ,
499+ auth ,
483500 ) ;
484501}
485502// twtr
@@ -504,8 +521,9 @@ export function importTwitter({
504521 : {
505522 epiweeks : epiRange ( firstEpiWeek . twitter , currentEpiWeek ) ,
506523 } ,
507- { auth , locations, resolution } ,
524+ { locations, resolution } ,
508525 [ 'num' , 'total' , 'percent' ] ,
526+ auth ,
509527 ) ;
510528}
511529export function importWiki ( {
0 commit comments