curl -fsSL "${my_key}/export?format=csv&usp=sharing&gid=${my_sheet}"

This is a real, working example, with multiple sheets.

If you click Share on a spreadsheet in Google Drive, you’ll get a link that you can convert into a CSV download link. It looks like this:

Note: To select a specific sheet you may need to manually click on the desired sheet’s tab and then manually select and copy the #gid=0000 part from the browser’s URL.


The quick, working example:

curl -fsSL ""

Download CSV from share link:

# The link, as copied from Google Sheets

# The key, extracted from the link: 1KdNsc63pk0QRerWDPcIL9cMnGQlG-9Ue9Jlf0PAAA34 
my_key="$(echo "${my_shared_link}" | cut -d'/' -f6)"

# The sheet, extracted from the link: 1440123577
my_sheet="$(echo "${my_shared_link}" | cut -d'#' -f2 | cut -d '=' -f2)"

# The OLD curl command, for reference
# curl -fsSL -o test.csv "${my_key}&usp=sharing&output=csv"

# The current version, translatable into ANY programming language
curl -fsSL -o test.csv "${my_key}/export?format=csv&usp=sharing&gid=${my_sheet}"

# The proof it still works in 2022
cat test.csv


The quick, working example:

"use strict";

let resp = await require("@root/request")({
  url: "",

Download CSV from share link:

"use strict";

let request = require("@root/request");

let shareLink =
  process.argv[2] ||

let out = process.argv[3] || "./test.csv";

let url = new URL(shareLink);
// 1KdNsc63pk0QRerWDPcIL9cMnGQlG-9Ue9Jlf0PAAA34
let key = url.pathname.split("/")[3];
// 1440123577
let sheet = '';
if (/gid/.test(url.hash) {
  sheet = url.hash.replace(/#gid=(\w+)\b.*/, "$1");

async function main() {
  let query = {
    format: "csv",
    usp: "sharing",
  if (sheet) {
    query.gid = sheet;
  let search = new URLSearchParams(query).toString();
  let csvUrl = `${key}/export?${search}`;`Downloading ${csvUrl} ...`);
  let resp = await request({
    url: csvUrl,
    stream: out,

  await;`Wrote ${out}`);

main().catch(function (err) {
  cosole.error("Fail:", err);


See also: