Question

Adding date range to responses Get request

  • 4 September 2023
  • 8 replies
  • 186 views

Hi all,

Can anyone confirm if the ‘since’ and ‘until’ query parameters work on their API GET requests?

I have a curl function with the dates formatted in the exact same format as stated in here: Responses API walkthroughs (typeform.com). However, it does not pull unless I take the date range parameters out.

Is this feature working?

Thanks


8 replies

Userlevel 7
Badge +5

Hi @Spidey Thanks for asking! These parameters do work. Can you send over the call you’re making? Thanks!

Userlevel 3
Badge

Here I tried the exact same thing as the OP and it seems to work really well - here’s the evidence:

 

app.dashcam.io/share/rGHvmV8ZCn75uPC64ssvjQ

 

First I try to retrieve a record from the future: It returns a successful empty array
 Then I try to retrieve a record within a good timeframe: It finds it as expected
 Then I try to retrieve a record with a different filter…and it works again.
 If you have issues the trick might be to encode the timestamp properly

Userlevel 7
Badge +5

Tagging @mathio in case they have any advice!

Userlevel 7
Badge +5

Hello, I worked with it recently and it worked fine. Can you please provide more information? Ideally the script or at least curl command you are trying to execute.

Userlevel 7
Badge +5

Hi @okdashcam @Spidey Were you two able to solve the issue? If you could send over the call you’re making, that would be helpful!

Userlevel 3
Badge

Hi @okdashcam @Spidey Were you two able to solve the issue? If you could send over the call you’re making, that would be helpful!

I have no issues, in fact it works perfectly fine on my end I was just showing some video evidence of how well it works 💪

Hi all, apologies, just returned from annual leave. Here is the code I was attempting:

 

from subprocess import Popen, PIPE
import pandas as pd
import subprocess
import json
import os
import sys
import time
import requests 

 

FormID = [MY FORM ID]
authToken = [MY AUTH TOKEN]

# Define start and end times for data pull (up to seconds)
start_date = '2023-08-16 08:00:00'
end_date = '2023-08-24 18:00:00'

# Formatting to get in the correct form for the API callstart_datetime = start_datetime + 'Z'
start_date = start_date + 'Z'
start_date = start_date.replace(' ','T').replace(':','%3A')
end_date = end_date + 'Z'
end_date = end_date.replace(' ','T').replace(':','%3A')
 

command = "curl --request GET 'https://api.typeform.com/forms/" + FormID + '/responses?since=' + start_date + '&until=' + end_date + "'" + " --header 'authorization: bearer " + authToken + "'"
print(command)
sp = subprocess.Popen(command, shell=True,stdout=subprocess.PIPE)
print(sp)
b = sp.stdout.read()
print(b)
a = b.decode('utf-8')
print(a)
out = json.loads(a)

 

(It generates:

curl --request GET 'https://api.typeform.com/forms/FORMID/responses?since=2023-08-16T08%3A00%3A00Z&until=2023-08-24T18%3A00%3A00Z' --header 'authorization: bearer TOKEN' )
Userlevel 7
Badge +5

Sorry I am not skilled in Python. However when I tried the curl command you provided (with correct FORMID and TOKEN values) it worked just fine.

Maybe the issue is not with the curl command but rather with the Python code? 🤔 Sorry I could not be of more help.

Reply