# @devrev/typescript-sdk

> ## SDK Generation

Latest version **1.1.79** (published 2026-10-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @devrev/typescript-sdk
pnpm add @devrev/typescript-sdk
yarn add @devrev/typescript-sdk
bun add @devrev/typescript-sdk
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.1.79 |
| Published | 2026-10-09 |
| First published | 2023-04-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 3.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | devrev |
| Maintainers | devrev-npm, mladenba |

## Links

- npm: https://www.npmjs.com/package/@devrev/typescript-sdk
- Repository: https://github.com/devrev/typescript-sdk
- Homepage: https://github.com/devrev/typescript-sdk#readme
- Issues: https://github.com/devrev/typescript-sdk/issues
- npm.io page: https://npm.io/package/@devrev/typescript-sdk

## Dependencies (5)

- [axios](https://npm.io/package/axios.md) 1.20.0
- [yargs](https://npm.io/package/yargs.md) ^17.6.2
- [dotenv](https://npm.io/package/dotenv.md) ^16.0.3
- [protobufjs](https://npm.io/package/protobufjs.md) ^7.6.3
- [@types/yargs](https://npm.io/package/@types/yargs.md) ^17.0.22

## Recent versions

- 1.1.79 (latest) — 2026-10-09
- 1.1.78 — 2026-06-14
- 1.1.77 — 2026-06-10
- 1.1.76 — 2026-06-01
- 1.1.75 — 2026-05-23
- 1.1.74 — 2026-05-05
- 1.1.73 — 2026-04-29
- 1.1.72 — 2026-04-13
- 1.1.71 — 2026-02-19
- 1.1.70 — 2025-09-17
- 1.1.69 — 2025-09-12
- 1.1.68 — 2025-07-30
- 1.1.67 — 2025-07-15
- 1.1.66 — 2025-07-08
- 1.1.65 — 2025-07-01
- … 60 more at https://npm.io/package/@devrev/typescript-sdk/versions

## README

# Authorization

Setup an env variable `DEVREV_TOKEN` It will be used as an auth token by default, You can also pass in the url and token in `client.setup()` as a param (see below). It is also required to run tests.

# Installation

```
npm install @devrev/typescript-sdk
```
The version can be found in package.json. The SDK is currently beta.
Make sure that your project's **package.json** contains `"type":"module"` setting.

# Example Usage of the Beta SDK

```
import {client, betaSDK} from "@devrev/typescript-sdk";

const devrevBetaSDK = client.setupBeta({ endpoint: "https://api.devrev.ai",
token: process.env.DEVREV_TOKEN });

async function test(){
    const response = await devrevBetaSDK.worksCreate({title:"New work item!",
    applies_to_part: "PROD-1",
    owned_by:["DEVU-1"],
    type: betaSDK.WorkType.Issue})
    console.log(response)
}

test()

```

# Example Usage of the Public SDK

```
import {client, publicSDK} from "@devrev/typescript-sdk";

const devrevSDK = client.setup({ endpoint: "https://api.devrev.ai", token: process.env.DEVREV_TOKEN });

async function test(){
    const response = await devrevSDK.worksCreate({title:"New work item!", applies_to_part: "PROD-1", owned_by:["DEVU-16"], type: publicSDK.WorkType.Issue})
    console.log(response.status)
}

test()
```

# Execute tests in the repo
```
npm test
```

# Devrev SDK Utils Guide

## Basic Setup

First, initialize the SDK with your DevRev credentials:

```typescript
import { client } from '@devrev/typescript-sdk';
import { BetaSdkUtil } from '@devrev/sdk-utils';

// Initialize the DevRev SDK
const devrevSDK = new client.setupBeta({
  // Your DevRev credentials
  endpoint: "https://api.devrev.ai",
  token: "YOUR_TOKEN"
});

// Initialize the utils SDK
const sdkUtil = new BetaSdkUtil(devrevSDK);
```

## Core Features

### 1. User Management

Fetch all Rev users associated with an account:

```typescript
const accountId = "ACC-12345";
const revUsers = await sdkUtil.getAllRevUsersFromAccount(accountId);
// Returns array of RevUser objects
```

### 2. File Management

#### Upload Files
```typescript
import { FileTypes } from '@devrev/sdk-utils';

// Prepare file object
const fileObject = {
  file_name: "example.txt",
  file_type: FileTypes.OTHERS,
  file: Buffer.from("Hello World"),
  custom_file_type: "text/plain" // Required when file_type is OTHERS
};

// Upload file
const artifactId = await sdkUtil.uploadFileToArtifact(fileObject);
```

#### Retrieve File Content
```typescript
const artifactId = "ART-12345";
const fileContent = await sdkUtil.getFileContentFromArtifact(artifactId);
```

## Error Handling

The SDK includes built-in `API` error handling that provides detailed error information:

```typescript
try {
  await sdkUtil.uploadFileToArtifact(fileObject);
} catch (error) {
  // Error will be automatically handled with detailed logging:
  // === Error Details ===
  // Service: [function name]
  // API: [API endpoint]
  // Error Type: [error type]
  // Status Code: [status code]
  // Message: [error message]
}
```

## TypeScript Support

The SDK is written in TypeScript and provides comprehensive type definitions for:
- File management operations
- User management
- API Error handling

## How to Contribute?

1. **Create a New Branch**  
   - Start by creating a separate branch for your feature or bug fix.  

2. **Follow Best Coding Practices**  
   - Ensure your code adheres to the following guidelines:  
     - Handle potential errors using `try-catch` blocks.  
     - Use TypeScript types/interfaces from the SDK for type safety.  
     - Check file type requirements before uploading.  
     - Utilize built-in API error handling for consistent logging.  

3. **Enhance `BetaSDKUtil`**  
   - Modify the `BetaSDKUtil` class to add new utilities.  
   - Write comprehensive test cases to ensure functionality.  

4. **Run Tests**  
   - Execute tests using:  
     ```
     npm test
     ```

5. **Submit a Pull Request**  
   - Open a pull request with a clear and detailed description of your changes.

---
_Source: https://npm.io/package/@devrev/typescript-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
