https://github.com/webpractik/ocf-converter-sdk-ts
SDK for onlineconvertfree.com file conversion API
https://github.com/webpractik/ocf-converter-sdk-ts
api sdk
Last synced: 9 months ago
JSON representation
SDK for onlineconvertfree.com file conversion API
- Host: GitHub
- URL: https://github.com/webpractik/ocf-converter-sdk-ts
- Owner: webpractik
- License: mit
- Created: 2022-11-15T11:18:32.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T08:59:18.000Z (over 3 years ago)
- Last Synced: 2025-07-30T13:05:57.910Z (9 months ago)
- Topics: api, sdk
- Language: TypeScript
- Homepage: https://onlineconvertfree.com/file-conversion-api/
- Size: 26.4 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ocf-converter-sdk for TypeScript
SDK for [onlineconvertfree.com](https://onlineconvertfree.com/) [file conversion API](https://onlineconvertfree.com/file-conversion-api/).
## Installation & Usage
### Requirements
Node.js 16.15.1.
### Install
```shell
npm install ocf-converter-sdk
```
## Getting Started
Please follow the [installation procedure](#installation--usage) and then start from the following:
```typescript
import * as fs from 'fs';
import * as https from 'https';
import { OcfClient } from 'ocf-converter-sdk';
const apiKey = 'myApiKey';
const client = new OcfClient(apiKey);
const filePath = '/path/to/file/to/convert.png';
const extensionToConvertTo = 'pdf';
const task = await client.uploadFile(filePath, extensionToConvertTo);
const result = await task.waitForConversion();
if (result.isSuccess()) {
const resultUrl = result.getResultingFileUrl() as string;
await new Promise((resolve, reject) => {
https.get(resultUrl, (response => {
const path = `${__dirname}/result.${extensionToConvertTo}`;
const filePath = fs.createWriteStream(path);
response.pipe(filePath);
filePath.on('finish', async () => {
filePath.close();
await result.deleteFile();
resolve(0);
}).on('error', error => reject(error));
})).on('error', error => reject(error));
});
}
```
## License
SDK is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information.
## Contribution
[OpenAPI Typescript Codegen](https://github.com/ferdikoomen/openapi-typescript-codegen/) is used for the client generation.
### Requirements
[OpenAPI Typescript Codegen](https://github.com/ferdikoomen/openapi-typescript-codegen/) is required for the client generation.
### Client generation
To regenerate the client do the following:
- run generation command:
```shell
npm run api-codegen
```
- reformat the generated code with your IDE.