This JavaScript client helps you interact with the Stein API, both in the browser and in Node.js setups.
To setup the client on your front-end, add this external script in the <head>
of your page.
<script src="https://unpkg.com/stein-js-client"></script>
To install the package via NPM, run
npm install stein-js-client
And import it in your files.
const SteinStore = require("stein-js-client");
A store is a reference to a spreadsheet API.
Each store is initialised by providing the API URL.
const store = new SteinStore(
"https://api.steinhq.com/v1/storages/5cca0542e52a3545102c1665"
);
You can now interact with the API using the methods on the store.
Parameter | Description | Format | Requirement |
---|---|---|---|
limit | Maximum number of rows to be returned | Number | Optional |
offset | Number of rows to be skipped (from the start) | Number | Optional |
authentication | Basic HTTP Authentication , if required by the API | {username, password} | Optional |
search | The column values to search for | {column: value, ...} | Optional |
This returns a promise which resolves providing an array of rows, with each row in the format {column: value}
. On error, the promise rejects with the message.
const store = new SteinStore(
"https://api.steinhq.com/v1/storages/5cc158079ec99a2f484dcb40"
);
store
.read("Sheet1", { limit: 1, offset: 2, search: { author: "Shiven Sinha" } })
.then(data => {
console.log(data);
});
Parameter | Description | Format | Requirement |
---|---|---|---|
authentication | Basic HTTP Authentication , if required by the API | {username, password} | Optional |
This returns a promise which resolves providing the updated range, e.g. { "updatedRange": "Sheet1!A6:D6" }
. On error, the promise rejects with the message.
const store = new SteinStore(
"https://api.steinhq.com/v1/storages/5cc158079ec99a2f484dcb40"
);
store
.append("Sheet2", [
{
title: "Awesome article",
author: "Me!",
content: "A brief summary",
link: "blog.me.com/awesome-article"
}
])
.then(res => {
console.log(res);
});
Parameter | Description | Format | Requirement |
---|---|---|---|
search | The column values to search for | {column: value, ...} | Required |
set | The column values to set | {column: value, ...} | Required |
limit | Maximum number of rows to be updated | Number | Optional |
authentication | Basic HTTP Authentication , if required by the API | {username, password} | Optional |
This returns a promise which resolves providing the updated range, e.g. { "updatedRange": "Sheet1!A6:D6" }
. On error, the promise rejects with the message.
const store = new SteinStore(
"https://api.steinhq.com/v1/storages/5cc158079ec99a2f484dcb40"
);
store
.edit("Sheet1", {
search: { author: "Shiven Sinha" },
set: { title: "Currently Unavailable" }
})
.then(res => {
console.log(res);
});
Parameter | Description | Format | Requirement |
---|---|---|---|
search | The column values to search for | {column: value, ...} | Required |
limit | Maximum number of rows to be updated | Number | Optional |
authentication | Basic HTTP Authentication , if required by the API | {username, password} | Optional |
This returns a promise which resolves providing the updated range, e.g. { "updatedRange": "Sheet1!A6:D6" }
. On error, the promise rejects with the message.
const store = new SteinStore(
"https://api.steinhq.com/v1/storages/5cc158079ec99a2f484dcb40"
);
store
.delete("Sheet1", {
search: { author: "Shiven Sinha" }
})
.then(res => {
console.log(res);
});
Find additional documentation and guides on docs.steinhq.com.
The Stein JavaScript client is MIT licensed.