There are two ways to do this:
npm install sheet2api-js --save
import Sheet2API from 'sheet2api-js';
const url = 'https://sheet2api.com/v1/FgI6zV8qT121/characters/';
const options = {};
Sheet2API.read(url, options).then(function(result){
console.log(result);
}, function(error){
console.log(error);
});
Here are some ready to use Excel Online API examples using the JavaScript client. Simply copy them into your project and you're good to go.
Read all rows
// Returns all rows from the first Sheet.
import Sheet2API from 'sheet2api-js';
const url = 'https://sheet2api.com/v1/FgI6zV8qT121/characters/';
const options = {};
Sheet2API.read(url, options).then(function(result){
console.log(result);
}, function(error){
console.log(error);
});
Read rows which match search terms
// Returns all rows from the first Sheet, filtered by search terms.
import Sheet2API from 'sheet2api-js';
const url = 'https://sheet2api.com/v1/FgI6zV8qT121/characters/';
const options = {query: { 'Name': 'Bugs Bunny' }};
Sheet2API.read(url, options).then(function(result){
console.log(result);
}, function(error){
console.log(error);
});
Add a new row
// Adds a new row to the Sheet.
import Sheet2API from 'sheet2api-js';
const url = 'https://sheet2api.com/v1/FgI6zV8qT121/characters/';
const newRowData = { 'Favourite Thing': 'Carrots', 'Name': 'Bugs Bunny' };
const options = {};
Sheet2API.write(url, options, newRowData).then(function(result){
console.log(result);
}, function(error){
console.log(error);
});
Update existing rows matching a search query
// Adds a new row to the Sheet.
import Sheet2API from 'sheet2api-js';
const url = 'https://sheet2api.com/v1/FgI6zV8qT121/characters/';
const updateWithData = { "Favourite Thing": "Beer", "Name": "Bugs Bunny" };
const options = {query: { 'Name': 'Bugs Bunny' }};
Sheet2API.update(url, options, updateWithData).then(function(result){
console.log(result);
}, function(error){
console.log(error);
});
For more in-depth examples check out the Github code repository.
It's as easy as that 🎉.
If you need help, please feel free to send a message via the contact page.