rapicurlamplitude-analytics

How to call Amplitude Export API with R


I am trying to call the Amplitude Export API (link here: https://developers.amplitude.com/docs/export-api) with R.

Below is the explanation but I really don't see how to apply the following using a function like GET or curl functions.

curl -u API_Key:Secret_Key 'https://amplitude.com/api/2/export?start=20150201T5&end=20150203T20' >> yourfilename.zip

Solution

  • No really an R expert but something like this should work

    require(httr)
    
    params = list(
      `start` = '20150201T5',
      `end` = '20150203T20'
    )
    
    res <- httr::GET(url = 'https://amplitude.com/api/2/export', query = params, httr::authenticate('API_Key', 'Secret_Key'))