0.3.0 • Published 6 months ago

bimg-new v0.3.0

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
6 months ago

Bimg

NPM NPM Downloads

A npm package of reverse-engineered Bing Image Creator API. Courtesy of Bing Image Search API and EdgeGPT by acheong08.

Installation

npm install bimg-new

Usage

Set environment variables

Create a .env file in the root directory of your project and add the cookie of your Bing Image Search session. You need access to Bing Image Creator or a valid cookie from someone who has access.

The cookie you need from Bing is the _U cookie, this could be aquired using a chrome-extension or by using the Network tab in Chrome DevTools.

BING_IMAGE_COOKIE: <your Bing Image Search cookie>

Import the package

import { generateImageFiles, generateImagesLinks, obtainImageFiles, obtainImagesLinks,createImagesFromBing } from "bimg";

const imageLinks = await generateImagesLinks(prompt); // returns an array of 4 image links
const imageFiles = await generateImageFiles(prompt); // returns an array of 4 image files

const handleRedirect = (requestId: string, redirectUrl: string) => {
  // handle redirect logic
  console.log(`Received redirect request with ID ${requestId}. Redirecting to ${redirectUrl}.`);
}
// invoke generateImageFiles or generateImagesLinks function with handleRedirect callback
const imageLinks = await generateImagesLinks(prompt, handleRedirect); // returns an array of 4 image links
const imageFiles = await generateImageFiles(prompt, handleRedirect); // returns an array of 4 image files

// obtain images by requestId
const imageLinks = await obtainImagesLinks(requestId); // returns an array of 4 image links
const imageFiles = await obtainImageFiles(requestId); // returns an array of 4 image files


// obtain images by requestId
const imageLinks = await createImagesFromBing(prompt); // returns an array of 4 image links

The image file is a object of

{
  name: string,
  data: string   // base64 encoded image data from Buffer
}

Examples

See my simple expressjs server here.

0.3.0

6 months ago

0.2.9

6 months ago

0.2.8

6 months ago

0.2.7

6 months ago

0.2.6

6 months ago

0.2.5

6 months ago

0.2.4

6 months ago

0.2.3

6 months ago

0.2.2

6 months ago

0.2.1

6 months ago

0.2.0

7 months ago

0.1.9

7 months ago

0.1.8

7 months ago

0.1.7

7 months ago

0.1.6

7 months ago