Download using API and compress the results

Is it possible to download using API and get the json results in a compressed file?


@raffy_m, maybe this post discussed previously should help you solve your issue:

Hi @Kal_Lam ,

The quoted response does not answer my question which is how to get the results, when downloading using API. JSON which is compressed and not plain text. Thanks

Hi @raffy_m, you can look at the headers sent by the browser as it requests a compressed file and then deflates it. Here I’ve just copied the header 'Accept-Encoding: gzip, deflate, br':


curl -H "Authorization: Token $TOKEN" \
  -H 'Accept-Encoding: gzip, deflate, br' \
  -o data.gz \
ls -lah data.gz
-rw-r--r--  1 josh  staff   644B Jun 16 10:33 data.gz

Deflate the file:

gzip -dk data.gz

See the size difference of the deflated JSON data:

ls -lah data*                                                                                                             
-rw-r--r--  1 josh  staff   2.1K Jun 16 10:39 data
-rw-r--r--  1 josh  staff   644B Jun 16 10:39 data.gz
1 Like