# @volcengine/imagex-openapi

> 火山引擎视频云 Nodejs SDK，提供完备的 OPENAPI 请求调用能力

Latest version **2.2.0** (published 2023-09-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @volcengine/imagex-openapi
pnpm add @volcengine/imagex-openapi
yarn add @volcengine/imagex-openapi
bun add @volcengine/imagex-openapi
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2023-09-26 |
| First published | 2022-10-09 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 9 |
| Unpacked size | 68.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | VCloud-FE |
| Maintainers | bytedance_liutaofe, ash.yu, zhenran.sz, vcloud_fe, zhuhongshuyu, wangyx.byte, shushushu, zhoulei, shanggw, liangshuang.fiona, zhengwenyue, wallaceyuan, cmaxd, liuzhao.90, liucheng.bigorange, zhouyk, oanakiaja, chenyongjin, lixiangfeiorg, awesome-starling, zhang6464, volcanoengine, bytednpm |
| Keywords | vcloud, 视频云, vod, 视频点播 |

## Links

- npm: https://www.npmjs.com/package/@volcengine/imagex-openapi
- npm.io page: https://npm.io/package/@volcengine/imagex-openapi

## Dependencies (9)

- [ajv](https://npm.io/package/ajv.md) ^8.11.0
- [crc](https://npm.io/package/crc.md) ^4.1.1
- [lodash.get](https://npm.io/package/lodash.get.md) ^4.4.2
- [lodash.omit](https://npm.io/package/lodash.omit.md) ^4.5.0
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2
- [@types/lodash.get](https://npm.io/package/@types/lodash.get.md) ^4.4.7
- [@types/lodash.omit](https://npm.io/package/@types/lodash.omit.md) ^4.5.7
- [@types/lodash.merge](https://npm.io/package/@types/lodash.merge.md) ^4.6.7
- [@volcengine/vcloud-core](https://npm.io/package/@volcengine/vcloud-core.md) 1.0.6

## Recent versions

- 2.2.0 (latest) — 2023-09-26
- 2.1.0 — 2023-05-22
- 1.1.0 — 2023-03-28
- 1.0.12 — 2023-02-01
- 1.0.1 — 2022-12-13
- 1.0.0 — 2022-10-09

## README

# @volcengine/imagex-openapi

[中文版](./README.zh_CN.md)
## Documentation

The documentation for the Volcengine VCloud API can be found [here](https://www.volcengine.com/docs)

The documentation for the nodejs SDK API can be found [here](/docs/VodOverview.md)

The documentation for the Volcengine AK&SK can be found [here](https://www.volcengine.com/docs/6291/65568)

## Versions

`@volcengine/imagex-openapi` uses a modified version of [Semantic Versioning](https://semver.org) for all changes. 

### Supported Node.js Versions

This library supports Nodejs version 12 and above.

## Sample Usage

### Setting OpenAPI service's AK&SK

Available in three settings

#### 1. By class initial options to set AK&SK

```javascript

import VolcSdk from '@volcengine/imagex-openapi';

const client = new VolcSdk({
  accessKey: 'your own accessKey',
  secretKey: 'your own secretKey'
});
```

#### 2. Use environment variables to set AK & SK

```bash
VOLC_ACCESSKEY="your ak" VOLC_SECRETKEY="your sk"
```

#### 3. Use configuration file

Put it in ~/.volc/config in json format, the format is:

```json
{"VOLC_ACCESSKEY":"your ak","VOLC_SECRETKEY":"your sk"}
```

### Specify Region and/or Host

You could specify the target Region and/or Host for the client:

```javascript
import VCloudSdk from '@volcengine/imagex-openapi';

const client = new VCloudSdk({
  accessKey: 'your own accessKey',
  secretKey: 'your own secretKey',
  region: 'cn-north-1',
  host: 'open.volcengineapi.com'
});
```

### Logging and custom log

To log this SDK request, you could set the logLevel or set your own application log policy by setting LoggerOptions.log method.

```javascript
import VCloudSdk from '@volcengine/imagex-openapi';
import winston from 'winston';

const appLogger = winston.createLogger();

const client = new VCloudSdk({
  accessKey: 'your own accessKey',
  secretKey: 'your own secretKey',
  loggerOptions: {
    level: 'debug',
    log: function(opts) {
      appLogger.log(opts);
    },
  },
});
```

### Using a Custom HTTP Request Client

The Volcengine VCloud nodejs SDK uses axios, a promise-based HTTP client, to make requests. You can also provide your own httpClient to customize requests as needed.

```javascript
import VCloudSdk from '@volcengine/imagex-openapi';
import customHttpRequest from './customHttpRequest';

const client = new VCloudSdk({
  accessKey: 'your own accessKey',
  secretKey: 'your own secretKey',
  region: 'cn-north-1',
  host: 'open.volcengineapi.com',
  httpRequest: customHttpRequest,
});
```

Write a custom HTTP client 

```javascript
async function request(url, options) {
  const { headers = {}, proxy, maxBodyLength = 0 } = options;
  const reqOption: AxiosRequestConfig = {
    url,
    ...options,
    headers: {
      ...headers,
      'User-Agent': 'your own user agent'
    }
  };
  try {
    const res = await axios(reqOption);
    return {status: res.status, body: res.data, headers: res.headers};
  } catch(e) {
    // report metrics and so on...
  }
}
```

Use a custom HTTP client with this SDK, you could mock the Volcengine API responses, and run your unit and integration tests quickly without the need to make a connection to Volcengine.

### plugin

If the current features can't meet your needs, you can try to write a custom plugin following the next format

```javascript
function plugin () {
  return async (context, next) => {
    // ...
    // execute before send request
    await next() // execute the rest plugins and send request at last
    // execute after send request
    // ...
  }
}
```

there is a simple example

```javascript
export default function accessPlugin() {
    return async (context, next) => {
        if(checkAccess()) {
          await next();
        } else {
          context.response = 'has no access';
        }
        return;
    };
}
```

then you need to register this plugin to a client

```javascript
const client = new VCloudSdk({
  accessKey: 'your own accessKey',
  secretKey: 'your own secretKey',
  region: 'cn-north-1',
  host: 'open.volcengineapi.com',
  httpRequest: customHttpRequest,
});
client.addPlugin(accessPlugin);
```

## Proxy Settings

To make request via a proxy host, you could set the proxy options.

#### 1. By class initial options to set proxy

```javascript
import VCloudSdk from '@volcengine/imagex-openapi';

const client = new VCloudSdk({
  accessKey: 'your own accessKey',
  secretKey: 'your own secretKey', 
  proxy: {
      protocol: 'https',
      host: 'your own proxy host ip',
      auth: 'your own proxy host auth',
      port: 8080, // your own proxy host port
  }
});
```

#### 2.Use environment variables to set proxy.

`VOLC_PROXY_HOST="your own proxy host" VOLC_PROXY_PORT="your own proxy host port" `

## Getting help

If you need help installing or using the sdk, please check the [Volcengine Support Help Center](https://www.volcengine.com/product/contact) first.

If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!

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