bassarisse / google-spreadsheet-to-json

Simple tool to export Google Spreadsheets to JSON files, though Node API or CLI
The Unlicense
134 stars 33 forks source link

node.js api #2

Closed cigolpl closed 8 years ago

cigolpl commented 8 years ago

Do you have in plan make it working not only by CLI but runnable by node.js code too ?

In my opinion it would be more flexible too if the result goes to the stdout instead saving to file then gsjson 1ZQotT7YZHyIrrIlrzuwMx9Eb8ofwy3PG7RP4a1JrU1o >> data.json

Anyway, very good job with that tool, works fine in CLI!

bassarisse commented 8 years ago

Yes, API for Node is something I'll implement soon, and the stdout idea is great, I'll try to address it too :) Thanks!

cigolpl commented 8 years ago

That's cool! :)

What do you think about doing API like that ?

var Gsjson = require('gsjson');

Gsjson({
  id: 'abc123456789',
  worksheet: 0,
  token: 'token',
  vertical: false,
  listOnly: false
}, function(err, data) {
  console.log(data)
});

Let me know If I could help because I would like to make integration google spreadsheet with https://github.com/itemsapi/itemsapi

bassarisse commented 8 years ago

That's exactly what I have in mind, but returning a Promise.

cigolpl commented 8 years ago

Yeah, Promise is even better :)

cigolpl commented 8 years ago

Hi @bassarisse, I've prepared PR #6 for this issue.

It has the same logic as before except saving result to file. Currently it is enough to gsjson spreadsheetid >> file.json or gsjson spreadsheetid | jq '.' (https://stedolan.github.io/jq/)

Additionally added some tests and simplified code and we can use it now as npm module (more details in example.js).

Let me know if that solution looks good for you - if yes then I can update docs and we can merge that

bassarisse commented 8 years ago

That's great. I merged and took the liberty of making some changes:

cigolpl commented 8 years ago

That looks cool, thanks!