3

More options for data refresh rate via API

I suggest to implement more options for the data refresh rate: once a week, every two weeks, once a month.

We are pulling data from Sistrix to Klipfolio via API. The Sistrix data refreshs once a week. The closest refresh rate in Klipfolio is to update every 24h. Unfortunately, our amount of Sistrix API credits doesn't cover 7 updates / week. That's why Klipfolio doesn't show Sistrix data by end of the week.

4 comments

  • 1
    Avatar
    Larona Nyambe

    Hello Johannes,

    You could try using Google scripts to request a data source refresh via our API and set a scheduled time for it to run. This is a feature of Google scripts. 

    Its a very simple process and I will walk you through it. 

    1. Go to https://script.google.com. 

    2. Copy and paste the code below into the script console (replace any piece of code you find):

    /*********
    * Use this script to refresh a data source
    * *******/

    var APIkey = 'Your Klipfolio API key';
    var dsID = 'Your data source ID';
    function refreshDS() {

    // Request headers
    var headers = {
    'kf-api-key': APIkey,
    'Content-Type': 'application/json'
    };
    //Request URL
    var url = 'https://app.klipfolio.com/api/1.0/datasource-instances/'+dsID+'/@/refresh';
    var options = {
    'method': 'post',
    'headers': headers,
    };

    // send the request
    var response = UrlFetchApp.fetch(url, options);
    //log the response
    Logger.log(response);


    }

    3. Press save. Update the variables APIKey and dsID with your klipfolio API key and your data source ID. To generate your API key if you don't have one already follow this link: https://support.klipfolio.com/hc/en-us/articles/215548478-Generate-a-Klipfolio-API-Key .

    4. Press the play button, allow the script permission to connect to an external device. If everything is done correctly the script will now run. You can check the response under view --> Logs (shortcut ctrl+enter).

    5. To create a trigger, click on the clock icon button, click the link to set up a trigger. Make sure the function refreshDS is selected. Choose your time unit and frequency, or enter a custom time. Press save! - You now have a time driven trigger for your data source refresh script, which works much like UNIX's cron job. 

     

    You could give that a try and see if it works for your use case. 

              ----Tass

  • 0
    Avatar
    Oliver Groth

    I'm looking for the solution like Johannes. Every week (or every tuesday, sunday...) would be nice.

    We've got the same credit issue with Searchmetrics.

    The workaround from Tass is ok for the moment, but why another place where a script works? In two years nobody knows how the data source is updated.

    Regards,

    Oliver

  • 1
    Avatar
    Tony Lu

    You can create a script in NodeJS and run it on AWS Lambda at any frequency you want - for free. 

     

    If you would like the code, let me know. 

     

  • 0
    Avatar
    Robert Manser

    Hi Eiren,

    I'm interested in - "You can create a script in NodeJS and run it on AWS Lambda at any frequency you want - for free. "

    are you able to provide sample code etc?

    thanks

Please sign in to leave a comment.