Search code examples
formstack

Formstack API parameters


I'm trying to use the Form Stack API to download some submissions onto my computer. I can download all submissions, but I would like to download records where the field is equal to some value (similar to using where in SQL).

It seems that the search_field_x and search_value_x options are used for this purpose but I can't get them to work.

Does anyone have an example on how to specify these parameters? I couldn't quite make sense of the docs here. That is, I did not understand what the values 1-10 represented.

This is the curl command I've been using. I have also used their online interface to pull the data, but the result is always the full set of submissions rather than a subset, which is what I'm after.

cstr='curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer secret_number" https://www.formstack.com/api/v2/form/form_id/submission.json?data=true\&page=1\&per_page=10\&search_field_x=School\&search_value_x="St.John" > my_data.json'

Solution

  • Here is a way to get filtered submissions back using the Formstack API:

    curl:

    curl -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer <bearer_number>" https://www.formstack.com/api/v2/form/<form_number>/submission.json?
    data=true\&page=1\&per_page=100\&search_field_1=<my_search_field_number>\&search_value_1=<my_search_value>
    

    or using python and requests:

    headers = {'Accept': 'application/json',
               'Content-Type': 'application/json',
               'Authorization': 'Bearer <bearer_number>'
               }
    
    params = {'data': 'true',
              'per_page': '100',
              'search_field_1': '<my_search_field_number>',
              'search_value_1': '<my_search_value>'
              }
    
    
    response = requests.get('https://www.formstack.com/api/v2/form/<my_form_id>/submission.json', headers=headers, params=params)
    json_data = json.loads(response.text)