togglcsv
togglcsv copied to clipboard
Can't export long time ranges
so Toggl time already allows export to CSV from the "Reports" tab, but they only allow exports for time ranges up to year. I thought this tool would help me get around that, but long time ranges give a 400 bad request
error, so I'm guessing the API has the same restrictions. You should specify this in the README. However,, alternatively I feel like you could manually do multiple requests and stitch together the exported CSVs into one large CSV.
togglcsv does split the time range into smaller chunk, issues one request against the Toggl API for each chunk and then stiches the results together.
I've just re-tested it with my personal account and I can fetch the records from last year until today:
togglcsv export 5xxxxxxxxxxxxxxxxxxf 2017-01-01

I chose to make the chunks the size of one month:
https://github.com/andreaskoch/togglcsv/blob/master/toggl/timereange.go#L25
Maybe that chunk size is too big for your account? The Limit is 1000 entries per request (see: https://github.com/toggl/toggl_api_docs/blob/master/chapters/time_entries.md#get-time-entries-started-in-a-specific-time-range). But that would not explain the 400 Bad Request response. 🤔
hmm, weird, I tried it again and it worked. Seems kind of inconsistent actually, and the longer I make the date range, the more likely it will fail. Probably the Toggl API servers acting up or something
I configured the API to do only only 1 request per second: https://github.com/andreaskoch/togglcsv/blob/e4fda9b7415c9029e98475496757e1771ffc4db2/vendor/github.com/andreaskoch/togglapi/api.go#L26
They recommend 1 second (see: https://github.com/toggl/toggl_api_docs#the-api-format) But maybe that's not enough if you are performing a lot of requests. But if that were the case they should return a HTTP 429 response.
But nevertheless, I can increase the wait time a bit ... or make it configurable if you like. And then you can try again.