1.0.0 • Published 2 years ago

cloudflare-images-ts v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Cloudflare Images API TypeScript Client

This library is a lightweight TypeScript client for Cloudflare Images API. It aims to provide a simple and efficient way to interact with the API.

Endpoints Status

EndpointMethodStatus
List images V2GETImplemented
Create Direct Upload URLPOSTImplemented
Update ImagePATCHImplemented
Delete ImageDELETEImplemented
List imagesGETNot planned (deprecated)
Upload an imagePOSTTBD
Images usage statisticsGETTBD
Base imageGETTBD
Image DetailsGETTBD

Installation

npm install cloudflare-images-ts
yarn add cloudflare-images-ts
pnpm add cloudflare-images-ts
bun install cloudflare-images-ts

Usage

First import the ImagesClient from the library:

import { ImagesClient } from "cloudflare-images-api-ts-client";

Then, create a new instance of the client with your Cloudflare credentials:

const client = new ImagesClient({
accessToken: "your-access-token",
accountIdentifier: "your-account-identifier",
});

List Images (V2)

To list images, use the listImages method:

const images = await client.listImages({});
images.result.images.forEach((image) => {
  console.log(image.requireSignedURLs);
});

Create Direct Upload URL

const uploadUrl = await client.createDirectUploadUrl({
  expiry: "2022-01-02T02:20:00Z",
  requireSignedURLs: true,
});
console.log(uploadUrl.result.uploadURL);

Update Image

To update an image, use the updateImage method:

const updatedImage = await client.updateImage({
  identifier: "image-identifier",
  requireSignedURLs: true,
});
console.log(updatedImage.result.requireSignedURLs);

Delete Image

To delete an image, use the deleteImage method:

await client.deleteImage({
  identifier: "image-identifier",
});

Please note that the other endpoints are not yet implemented in this library. Contributions are welcome!

1.0.0

2 years ago