How can I get the Questions (with IDs) when I retreive the responses) | Community
Skip to main content
Answered

How can I get the Questions (with IDs) when I retreive the responses)


Forum|alt.badge.img

Goo afternoon -

I am new to the Tyepform API - so please bear with me.

I am able to get the responses - but I need to be able to also download the questions also.

The answers contain the Question ID - but apart from creating all the questions off-line I can see of no way of getting the questions from the form …

Is this at all possible?

 

many thanks in advance,

 

BtB

Best answer by mathio-tf

Hello @bill-the-badger 

you can retrieve your full form definition along with all questions on:

https://api.typeform.com/forms/<form-id>

It is a public endpoint and needs no authentication. Hope this helps.

View original

8 replies

mathio-tf
Typeform
Forum|alt.badge.img+5
  • Typeform
  • 888 replies
  • Answer
  • June 23, 2022

Hello @bill-the-badger 

you can retrieve your full form definition along with all questions on:

https://api.typeform.com/forms/<form-id>

It is a public endpoint and needs no authentication. Hope this helps.


Forum|alt.badge.img

ach - that is perfect :-)

 

Many thanks indeed

 

BtB


Forum|alt.badge.img

I’m actually struggling to marry the responses to the questions … or vise-versa

Is it not possible within the response API to get the corresponding question?

 


mathio-tf
Typeform
Forum|alt.badge.img+5
  • Typeform
  • 888 replies
  • June 30, 2022

When you retrieve responses (see docs) you should get an object like this for each answer in each response:

          {
            "field": {
              "id": "hVONkQcnSNRj",
              "ref": "my_custom_dropdown_reference",
              "type": "dropdown"
            },
            "text": "Job opportunities",
            "type": "text"
          },

When you retrieve form definition (see docs) you will see both id and ref for each field. You can use id to pair fields & answers (refs are editable when building the form).


Forum|alt.badge.img

Mathio - many thanks, please excuse my late response …

The issue I had was due to the Matrix type of question / response … the ids are further nested than those from a simple question.

But I worked it out regardless.

BtB


Gabi Amaral
Ex–Typefomer
Forum|alt.badge.img+5
  • Ex–Typefomer
  • 1777 replies
  • July 6, 2022

Hey @bill-the-badger! Can you let us know what was the solution you've found? Thank you!


Forum|alt.badge.img

Hi Gabi - Certainly …(although you probably do not use the same syntax that I am using)

I loop through the responses, extracting the following:

$_current.answer = GetJSONObj ( $_array.answers ; $_loop.count ) ;

$_field = GetJSONObj ( $_current.answer ; "field" ) ;
$_type = GetJSONObj ( $_current.answer ; "type" ) ;
$_id = GetJSONObj ( $_field ; "id" ) ;

If $_type = "choice", then I need to get the answer from a different path @ GetJSONObj ( $_cur.answer ; "choice.label" )

I then filter the form questions based upon the current $_id - this will give me the matching question to the current answer, viz. GetJSONObj ( $_form.questions ; \"id\" ) = \"" & $_id & "\" " ) …

I need to massage the question a bit, again dependant on the answer type - but it work fine.

HtH

BtB


Forum|alt.badge.img

The issue I had is that in the matrix type of questions, the id is located further down in nested arrays … that is why I used a filter on ANY id, not just the first question id ...