Community Conundrum 27: Stacks of Questions is live! Read More

Use Public DSS API in a JavaScript WebApp

Level 2
Use Public DSS API in a JavaScript WebApp

In a Dataiku WebApp, I want to put a link to "export" a dataset in CSV.

This is covered by the "dataset / get data" entrypoint in the public API ( ).

But if I just put a link `<a href="https://mydataikuinstance/public/...">` the browser ask for credentials when I click on the link.


How could I proceed ? Is it possible to handle this entrypoint with the JavaScript dataiku library, as it is possible in Python with the dataikuapi library ?

0 Kudos
2 Replies


Indeed if you use the REST HTTP API you need to pass the API Key as explained in Public REST API Authentication. You will find an example in the provided webapp template: New webapp > Code webapp > Standard > Advanced web app using Dataiku REST API

The function of interest here is:

function dataikuREST(path, callback) {
    let url = '/public/api' + path;
    // We use fetch API (
    fetch(url, {
        headers: {
            'Authorization': 'Basic ' + btoa(dataiku.defaultAPIKey + ':' + '')
        .then(response => {
            if (response.ok) {
            } else {
                    err => displayMessage(err.message, 'error-message')

Else you can also use the python API:

You will find a code snippet here:

I hope this helps.


Mickaël | R&D at Dataiku
Level 2

Hi !

Thanks for your answer ! I've used the python backend, by more or less doing the same thing as explained in the link you provided.

from datetime import datetime
import dataiku
import pandas as pd
from flask import request, send_file, redirect, url_for

def export_study_users(studyId):
    # ... Prepare the dataset according to studyId, with variables, jobs ...
    now =
    now = now.strftime("%Y%m%d_%H%M%S")
    filename = f'users_{studyId}_{now}.xlsx'
    return redirect(url_for('export_study_users_file', studyId=studyId, filename=filename))

def export_study_users_file(studyId, filename):
    consumers = dataiku.Dataset(`{studyId}_consumers`)
    response = send_file(
    response.headers["x-filename"] = filename
    response.headers["x-suggested-filename"] = filename
    response.headers["Access-Control-Expose-Headers"] = 'x-filename'
    return response

But the `x-filename`headers seems blocked by the Flask configuration, so I'm not able to handle "properly" the download client-side ; I have to cheat 😕 

0 Kudos
Labels (1)