Node SDK Quickstart
Use the Drylab API in your node.js application using typescript.
1
2
3
Initialize a client
To start an HTTP client to communicate with the API, add the following to your application:
import { DrylabClient } from '@drylab/sdk-node';
const client = new DrylabClient({
apiKey: process.env.DRYLAB_API_KEY,
// The options below are optional and can be used to
// overide the client's defaults, if required
// 1. Additional custom headers to send with every request.
// Optional - useful for tracking, etc
headers: {
"X-Custom-Header": "value",
"X-Local-App-Version": "1.0.0",
},
// 2. User-Agent string
// Optional - useful for identifying your client in server logs
// Will be sent as "User-Agent" header
userAgent: "MyLocalApp/v0.1.0",
// 3. Request timeout in milliseconds
// Optional - defaults to 30,000 (30 seconds)
// Requests exceeding this time will be aborted
timeoutMs: 60000,
// 4. Maximum number of retry attempts for failed requests
// Optional - defaults to 2
// Retries occur for: network errors, 429 (rate limit), 5xx (server errors)
maxRetries: 3,
// 5. Generate idempotency keys for non-GET requests
// Optional - if omitted, the client will generate one
// automatically behind the scenes
idempotencyKey: `custom-key-${Date.now()}`
});
4
Use the SDK
You can now use the SDK! here is an example to get you started:
try {
console.log("Batch ingest (2 medrxiv items) request:");
// Batch-ingest two medrXiv preprints:
const res = await client.works.ingest({
works: [
{ externalIdType: "medrxivId", id: "2025.08.07.25333034" },
{ externalIdType: "medrxivId", id: "2025.08.07.25333034" },
]
});
console.log("Batch ingest (2 medrxiv items) response:", res);
} catch (err) {
// Catching errors if they occur:
if (err instanceof ApiError) {
console.error("API error:", err.status, err.body);
} else {
console.error("Unexpected error:", err);
}
}
Last updated