Skip to content

Commit 113b9a4

Browse files
feat(api): update via SDK Studio (#9)
1 parent 5b114e6 commit 113b9a4

File tree

1 file changed

+25
-31
lines changed

1 file changed

+25
-31
lines changed

README.md

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
This library provides convenient access to the Zeroentropy REST API from server-side TypeScript or JavaScript.
66

7-
The REST API documentation can be found on [docs.zeroentropy.dev](https://docs.zeroentropy.dev). The full API of this library can be found in [api.md](api.md).
7+
The REST API documentation can be found on [docs.zeroentropy.dev](https://docs.zeroentropy.dev/api-reference). The full API of this library can be found in [api.md](api.md).
88

99
## Installation
1010

@@ -25,9 +25,13 @@ const client = new Zeroentropy({
2525
});
2626

2727
async function main() {
28-
const response = await client.documents.getInfo({ collection_name: 'collection_name', path: 'path' });
28+
const response = await client.documents.add({
29+
collection_name: 'example_collection',
30+
content: { type: 'text', text: 'Example Content' },
31+
path: 'my_document.txt',
32+
});
2933

30-
console.log(response.document);
34+
console.log(response.message);
3135
}
3236

3337
main();
@@ -46,8 +50,7 @@ const client = new Zeroentropy({
4650
});
4751

4852
async function main() {
49-
const params: Zeroentropy.DocumentGetInfoParams = { collection_name: 'collection_name', path: 'path' };
50-
const response: Zeroentropy.DocumentGetInfoResponse = await client.documents.getInfo(params);
53+
const response: Zeroentropy.StatusGetStatusResponse = await client.status.getStatus();
5154
}
5255

5356
main();
@@ -64,17 +67,15 @@ a subclass of `APIError` will be thrown:
6467
<!-- prettier-ignore -->
6568
```ts
6669
async function main() {
67-
const response = await client.documents
68-
.getInfo({ collection_name: 'collection_name', path: 'path' })
69-
.catch(async (err) => {
70-
if (err instanceof Zeroentropy.APIError) {
71-
console.log(err.status); // 400
72-
console.log(err.name); // BadRequestError
73-
console.log(err.headers); // {server: 'nginx', ...}
74-
} else {
75-
throw err;
76-
}
77-
});
70+
const response = await client.status.getStatus().catch(async (err) => {
71+
if (err instanceof Zeroentropy.APIError) {
72+
console.log(err.status); // 400
73+
console.log(err.name); // BadRequestError
74+
console.log(err.headers); // {server: 'nginx', ...}
75+
} else {
76+
throw err;
77+
}
78+
});
7879
}
7980

8081
main();
@@ -109,7 +110,7 @@ const client = new Zeroentropy({
109110
});
110111

111112
// Or, configure per-request:
112-
await client.documents.getInfo({ collection_name: 'collection_name', path: 'path' }, {
113+
await client.status.getStatus({
113114
maxRetries: 5,
114115
});
115116
```
@@ -126,7 +127,7 @@ const client = new Zeroentropy({
126127
});
127128

128129
// Override per-request:
129-
await client.documents.getInfo({ collection_name: 'collection_name', path: 'path' }, {
130+
await client.status.getStatus({
130131
timeout: 5 * 1000,
131132
});
132133
```
@@ -180,17 +181,13 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
180181
```ts
181182
const client = new Zeroentropy();
182183

183-
const response = await client.documents
184-
.getInfo({ collection_name: 'collection_name', path: 'path' })
185-
.asResponse();
184+
const response = await client.status.getStatus().asResponse();
186185
console.log(response.headers.get('X-My-Header'));
187186
console.log(response.statusText); // access the underlying Response object
188187

189-
const { data: response, response: raw } = await client.documents
190-
.getInfo({ collection_name: 'collection_name', path: 'path' })
191-
.withResponse();
188+
const { data: response, response: raw } = await client.status.getStatus().withResponse();
192189
console.log(raw.headers.get('X-My-Header'));
193-
console.log(response.document);
190+
console.log(response.num_documents);
194191
```
195192

196193
### Making custom/undocumented requests
@@ -294,12 +291,9 @@ const client = new Zeroentropy({
294291
});
295292

296293
// Override per-request:
297-
await client.documents.getInfo(
298-
{ collection_name: 'collection_name', path: 'path' },
299-
{
300-
httpAgent: new http.Agent({ keepAlive: false }),
301-
},
302-
);
294+
await client.status.getStatus({
295+
httpAgent: new http.Agent({ keepAlive: false }),
296+
});
303297
```
304298

305299
## Semantic versioning

0 commit comments

Comments
 (0)