1- # Spreadsheet API TypeScript API Library
1+ # GRID Spreadsheet API API Library
22
3- [ ![ NPM version] ( https://img.shields.io/npm/v/spreadsheet- api.svg )] ( https://npmjs.org/package/spreadsheet- api ) ![ npm bundle size] ( https://img.shields.io/bundlephobia/minzip/spreadsheet- api )
3+ [ ![ NPM version] ( https://img.shields.io/npm/v/@grid-is/ api.svg )] ( https://npmjs.org/package/@grid-is/ api ) ![ npm bundle size] ( https://img.shields.io/bundlephobia/minzip/@grid-is/ api )
44
5- This library provides convenient access to the Spreadsheet API REST API from server-side TypeScript or JavaScript.
5+ This library provides convenient access to the GRID REST API from server-side TypeScript or JavaScript.
66
7- The REST API documentation can be found on [ docs.spreadsheet-api.com ] ( https://docs.spreadsheet-api.com ) . The full API of this library can be found in [ api.md] ( api.md ) .
7+ The REST API documentation can be found on [ alpha.grid.is ] ( https://alpha.grid.is/ ) . The full API of this library can be found in [ api.md] ( api.md ) .
88
99It is generated with [ Stainless] ( https://www.stainlessapi.com/ ) .
1010
@@ -15,17 +15,17 @@ npm install git+ssh://git@github.com:stainless-sdks/spreadsheet-api-typescript.g
1515```
1616
1717> [ !NOTE]
18- > Once this package is [ published to npm] ( https://app.stainlessapi.com/docs/guides/publish ) , this will become: ` npm install spreadsheet- api `
18+ > Once this package is [ published to npm] ( https://app.stainlessapi.com/docs/guides/publish ) , this will become: ` npm install @grid-is/ api `
1919
2020## Usage
2121
2222The full API of this library can be found in [ api.md] ( api.md ) .
2323
2424<!-- prettier-ignore -->
2525``` js
26- import SpreadsheetAPI from ' spreadsheet- api' ;
26+ import GRID from ' @grid-is/ api' ;
2727
28- const client = new SpreadsheetAPI ();
28+ const client = new GRID ();
2929
3030async function main () {
3131 const response = await client .workbooks .query (' REPLACE_ME' , { read: [' A1' , ' Sheet2!B3' , ' =SUM(A1:A4)' ] });
@@ -42,13 +42,13 @@ This library includes TypeScript definitions for all request params and response
4242
4343<!-- prettier-ignore -->
4444``` ts
45- import SpreadsheetAPI from ' spreadsheet- api' ;
45+ import GRID from ' @grid-is/ api' ;
4646
47- const client = new SpreadsheetAPI ();
47+ const client = new GRID ();
4848
4949async function main() {
50- const params: SpreadsheetAPI .WorkbookQueryParams = { read: [' A1' , ' Sheet2!B3' , ' =SUM(A1:A4)' ] };
51- const response: SpreadsheetAPI .WorkbookQueryResponse = await client .workbooks .query (' REPLACE_ME' , params );
50+ const params: GRID .WorkbookQueryParams = { read: [' A1' , ' Sheet2!B3' , ' =SUM(A1:A4)' ] };
51+ const response: GRID .WorkbookQueryResponse = await client .workbooks .query (' REPLACE_ME' , params );
5252}
5353
5454main ();
@@ -68,7 +68,7 @@ async function main() {
6868 const response = await client .workbooks
6969 .query (' REPLACE_ME' , { read: [' A1' , ' Sheet2!B3' , ' =SUM(A1:A4)' ] })
7070 .catch (async (err ) => {
71- if (err instanceof SpreadsheetAPI .APIError ) {
71+ if (err instanceof GRID .APIError ) {
7272 console .log (err .status ); // 400
7373 console .log (err .name ); // BadRequestError
7474 console .log (err .headers ); // {server: 'nginx', ...}
@@ -105,7 +105,7 @@ You can use the `maxRetries` option to configure or disable this:
105105<!-- prettier-ignore -->
106106``` js
107107// Configure the default for all requests:
108- const client = new SpreadsheetAPI ({
108+ const client = new GRID ({
109109 maxRetries: 0 , // default is 2
110110});
111111
@@ -122,7 +122,7 @@ Requests time out after 1 minute by default. You can configure this with a `time
122122<!-- prettier-ignore -->
123123``` ts
124124// Configure the default for all requests:
125- const client = new SpreadsheetAPI ({
125+ const client = new GRID ({
126126 timeout: 20 * 1000 , // 20 seconds (default is 1 minute)
127127});
128128
@@ -136,6 +136,24 @@ On timeout, an `APIConnectionTimeoutError` is thrown.
136136
137137Note that requests which time out will be [ retried twice by default] ( #retries ) .
138138
139+ ## Default Headers
140+
141+ We automatically send the ` X-Client-Name ` header set to ` spreadsheet-api-node ` .
142+
143+ If you need to, you can override it by setting default headers on a per-request basis.
144+
145+ ``` ts
146+ import GRID from ' @grid-is/api' ;
147+
148+ const client = new GRID ();
149+
150+ const response = await client .workbooks .query (
151+ ' REPLACE_ME' ,
152+ { read: [' A1' , ' Sheet2!B3' , ' =SUM(A1:A4)' ] },
153+ { headers: { ' X-Client-Name' : ' My-Custom-Value' } },
154+ );
155+ ```
156+
139157## Advanced Usage
140158
141159### Accessing raw Response data (e.g., headers)
@@ -146,7 +164,7 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
146164
147165<!-- prettier-ignore -->
148166``` ts
149- const client = new SpreadsheetAPI ();
167+ const client = new GRID ();
150168
151169const response = await client .workbooks
152170 .query (' REPLACE_ME' , { read: [' A1' , ' Sheet2!B3' , ' =SUM(A1:A4)' ] })
@@ -222,7 +240,7 @@ Or pass it to the client:
222240``` ts
223241import fetch from ' my-fetch' ;
224242
225- const client = new SpreadsheetAPI ({ fetch });
243+ const client = new GRID ({ fetch });
226244```
227245
228246### Logging and middleware
@@ -232,9 +250,9 @@ which can be used to inspect or alter the `Request` or `Response` before/after e
232250
233251``` ts
234252import { fetch } from ' undici' ; // as one example
235- import SpreadsheetAPI from ' spreadsheet- api' ;
253+ import GRID from ' @grid-is/ api' ;
236254
237- const client = new SpreadsheetAPI ({
255+ const client = new GRID ({
238256 fetch : async (url : RequestInfo , init ? : RequestInit ): Promise <Response > => {
239257 console .log (' About to make a request' , url , init );
240258 const response = await fetch (url , init );
@@ -244,17 +262,17 @@ const client = new SpreadsheetAPI({
244262});
245263```
246264
247- Note that if given a ` SPREADSHEET_API_LOG =debug` environment variable, this library will log all requests and responses automatically.
265+ Note that if given a ` GRID_LOG =debug` environment variable, this library will log all requests and responses automatically.
248266This is intended for debugging purposes only and may change in the future without notice.
249267
250268### Fetch options
251269
252270If you want to set custom ` fetch ` options without overriding the ` fetch ` function, you can provide a ` fetchOptions ` object when instantiating the client or making a request. (Request-specific options override client options.)
253271
254272``` ts
255- import SpreadsheetAPI from ' spreadsheet- api' ;
273+ import GRID from ' @grid-is/ api' ;
256274
257- const client = new SpreadsheetAPI ({
275+ const client = new GRID ({
258276 fetchOptions: {
259277 // `RequestInit` options
260278 },
@@ -269,11 +287,11 @@ options to requests:
269287<img src =" https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/node.svg " align =" top " width =" 18 " height =" 21 " > ** Node** <sup >[[ docs] ( https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch )] </sup >
270288
271289``` ts
272- import SpreadsheetAPI from ' spreadsheet- api' ;
290+ import GRID from ' @grid-is/ api' ;
273291import * as undici from ' undici' ;
274292
275293const proxyAgent = new undici .ProxyAgent (' http://localhost:8888' );
276- const client = new SpreadsheetAPI ({
294+ const client = new GRID ({
277295 fetchOptions: {
278296 dispatcher: proxyAgent ,
279297 },
@@ -283,9 +301,9 @@ const client = new SpreadsheetAPI({
283301<img src =" https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/bun.svg " align =" top " width =" 18 " height =" 21 " > ** Bun** <sup >[[ docs] ( https://bun.sh/guides/http/proxy )] </sup >
284302
285303``` ts
286- import SpreadsheetAPI from ' spreadsheet- api' ;
304+ import GRID from ' @grid-is/ api' ;
287305
288- const client = new SpreadsheetAPI ({
306+ const client = new GRID ({
289307 fetchOptions: {
290308 proxy: ' http://localhost:8888' ,
291309 },
@@ -295,10 +313,10 @@ const client = new SpreadsheetAPI({
295313<img src =" https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/deno.svg " align =" top " width =" 18 " height =" 21 " > ** Deno** <sup >[[ docs] ( https://docs.deno.com/api/deno/~/Deno.createHttpClient )] </sup >
296314
297315``` ts
298- import SpreadsheetAPI from ' npm:spreadsheet- api' ;
316+ import GRID from ' npm:@grid-is/ api' ;
299317
300318const httpClient = Deno .createHttpClient ({ proxy: { url: ' http://localhost:8888' } });
301- const client = new SpreadsheetAPI ({
319+ const client = new GRID ({
302320 fetchOptions: {
303321 client: httpClient ,
304322 },
0 commit comments