JQL API Formatting

  • 19 February 2019
  • 5 replies


Hi all,

We are looking to include the result of a JQL query in our geckoboard for our APIs.

Geckoboard requires the data in the form of:

{"item": [ { "value": 5723 } ] }

Which is doable in JQL, however it returns this object inside of an array. i.e.

[{"item": [ { "value": 5723 } ] }]

Does anyone have any ideas how we could get the API to just return the object rather than the object inside an array?

Many thanks,




Best answer by michael 27 March 2019, 22:24

View original

5 replies

Userlevel 1

Are you able to return the first element in the array, like

return responseArray[0];


Hi @scott,

In theory yes.
When I try to have the function main() just return the first object of the array, I get the error:

Validate failed]main() must return a chain of transformations applied to a data source

Currently my last two transformations are

.map(function (object){
var output = {item: [{value: object}]}
return output

Which returns

"item": [
"value": 117

How would I go about returning the first value of this array?

Many thanks,



Userlevel 1

Hi I just typed up a response but it was all lost because this mixpanel community site has lots of bugs…

I do not have a live JQL environment so I cannot test, but it should go something like:

.reduce(function (accum,next){
   accum['item'] = next;
   return accum;


Hi Scott,

I know - I have done this exact thing, writing out a post then losing it, several times already.

Unfortunately this isnt working - whatever is returned is still returned inside of an array - I wonder if this is just the way JQL works, I have put a ticket into support so will see what they come back with.

Many thanks for your help, I do appreciated it!

Userlevel 4
Badge +2

Hi @benpeddie and @scott,

Please note that the JQL endpoint will always return an array of results at the base level, and I'm afraid there's no way to avoid having the outcome of JQL as an array at the base.

I do want to drill more into what insight this JQL is trying to accomplish for you, because after researching more into Geckoboard it looks like they have a widget you can use for a lot of our out of the box reports (Funnels, Retention, etc).

Is there a possibility that you can get this answer you are looking for and trying to display (or maybe most of it) by taking advantage of some of our default reporting tools?

Looking forward to continuing the discussion