1
1
# Cas Parser TypeScript API Library
2
2
3
- [ ![ NPM version] ( < https://img.shields.io/npm/v/cas-parser.svg?label=npm%20(stable) > )] ( https://npmjs.org/package/cas-parser ) ![ npm bundle size] ( https://img.shields.io/bundlephobia/minzip/cas-parser )
3
+ [ ![ NPM version] ( < https://img.shields.io/npm/v/cas-parser-node .svg?label=npm%20(stable) > )] ( https://npmjs.org/package/cas-parser-node ) ![ npm bundle size] ( https://img.shields.io/bundlephobia/minzip/cas-parser-node )
4
4
5
5
This library provides convenient access to the Cas Parser REST API from server-side TypeScript or JavaScript.
6
6
@@ -11,7 +11,7 @@ It is generated with [Stainless](https://www.stainless.com/).
11
11
## Installation
12
12
13
13
``` sh
14
- npm install cas-parser
14
+ npm install cas-parser-node
15
15
```
16
16
17
17
## Usage
@@ -20,7 +20,7 @@ The full API of this library can be found in [api.md](api.md).
20
20
21
21
<!-- prettier-ignore -->
22
22
``` js
23
- import CasParser from ' cas-parser' ;
23
+ import CasParser from ' cas-parser-node ' ;
24
24
25
25
const client = new CasParser ({
26
26
apiKey: process .env [' CAS_PARSER_API_KEY' ], // This is the default and can be omitted
@@ -38,7 +38,7 @@ This library includes TypeScript definitions for all request params and response
38
38
39
39
<!-- prettier-ignore -->
40
40
``` ts
41
- import CasParser from ' cas-parser' ;
41
+ import CasParser from ' cas-parser-node ' ;
42
42
43
43
const client = new CasParser ({
44
44
apiKey: process .env [' CAS_PARSER_API_KEY' ], // This is the default and can be omitted
@@ -50,35 +50,6 @@ const unifiedResponse: CasParser.UnifiedResponse = await client.casParser.camsKf
50
50
51
51
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
52
52
53
- ## File uploads
54
-
55
- Request parameters that correspond to file uploads can be passed in many different forms:
56
-
57
- - ` File ` (or an object with the same structure)
58
- - a ` fetch ` ` Response ` (or an object with the same structure)
59
- - an ` fs.ReadStream `
60
- - the return value of our ` toFile ` helper
61
-
62
- ``` ts
63
- import fs from ' fs' ;
64
- import CasParser , { toFile } from ' cas-parser' ;
65
-
66
- const client = new CasParser ();
67
-
68
- // If you have access to Node `fs` we recommend using `fs.createReadStream()`:
69
- await client .casParser .camsKfintech ({ pdf_file: fs .createReadStream (' /path/to/file' ) });
70
-
71
- // Or if you have the web `File` API you can pass a `File` instance:
72
- await client .casParser .camsKfintech ({ pdf_file: new File ([' my bytes' ], ' file' ) });
73
-
74
- // You can also pass a `fetch` `Response`:
75
- await client .casParser .camsKfintech ({ pdf_file: await fetch (' https://somesite/file' ) });
76
-
77
- // Finally, if none of the above are convenient, you can use our `toFile` helper:
78
- await client .casParser .camsKfintech ({ pdf_file: await toFile (Buffer .from (' my bytes' ), ' file' ) });
79
- await client .casParser .camsKfintech ({ pdf_file: await toFile (new Uint8Array ([0 , 1 , 2 ]), ' file' ) });
80
- ```
81
-
82
53
## Handling errors
83
54
84
55
When the library is unable to connect to the API,
@@ -190,7 +161,7 @@ The log level can be configured in two ways:
190
161
2 . Using the ` logLevel ` client option (overrides the environment variable if set)
191
162
192
163
``` ts
193
- import CasParser from ' cas-parser' ;
164
+ import CasParser from ' cas-parser-node ' ;
194
165
195
166
const client = new CasParser ({
196
167
logLevel: ' debug' , // Show all log messages
@@ -218,7 +189,7 @@ When providing a custom logger, the `logLevel` option still controls which messa
218
189
below the configured level will not be sent to your logger.
219
190
220
191
``` ts
221
- import CasParser from ' cas-parser' ;
192
+ import CasParser from ' cas-parser-node ' ;
222
193
import pino from ' pino' ;
223
194
224
195
const logger = pino ();
@@ -287,7 +258,7 @@ globalThis.fetch = fetch;
287
258
Or pass it to the client:
288
259
289
260
``` ts
290
- import CasParser from ' cas-parser' ;
261
+ import CasParser from ' cas-parser-node ' ;
291
262
import fetch from ' my-fetch' ;
292
263
293
264
const client = new CasParser ({ fetch });
@@ -298,7 +269,7 @@ const client = new CasParser({ fetch });
298
269
If 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.)
299
270
300
271
``` ts
301
- import CasParser from ' cas-parser' ;
272
+ import CasParser from ' cas-parser-node ' ;
302
273
303
274
const client = new CasParser ({
304
275
fetchOptions: {
@@ -315,7 +286,7 @@ options to requests:
315
286
<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 >
316
287
317
288
``` ts
318
- import CasParser from ' cas-parser' ;
289
+ import CasParser from ' cas-parser-node ' ;
319
290
import * as undici from ' undici' ;
320
291
321
292
const proxyAgent = new undici .ProxyAgent (' http://localhost:8888' );
@@ -329,7 +300,7 @@ const client = new CasParser({
329
300
<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 >
330
301
331
302
``` ts
332
- import CasParser from ' cas-parser' ;
303
+ import CasParser from ' cas-parser-node ' ;
333
304
334
305
const client = new CasParser ({
335
306
fetchOptions: {
@@ -341,7 +312,7 @@ const client = new CasParser({
341
312
<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 >
342
313
343
314
``` ts
344
- import CasParser from ' npm:cas-parser' ;
315
+ import CasParser from ' npm:cas-parser-node ' ;
345
316
346
317
const httpClient = Deno .createHttpClient ({ proxy: { url: ' http://localhost:8888' } });
347
318
const client = new CasParser ({
0 commit comments