npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cloreai

v4.0.2

Published

CLORE.AI API client

Readme

cloreai

CLORE.AI API client

Features:

  • Based on native fetch
  • Protects against rate limit exceeded (429 errors) through p-queue
  • Convenient error handling
  • Full type safety
  • Supports GigaSPOT

Official documentation: clore.ai/api-docs

Official GigaSPOT documentation: gigaspot-api-docs.clore.ai

Installation

npm install cloreai

Usage

Creating an instance

import Cloreai from 'cloreai'

const cloreai = new Cloreai('API_KEY', {
  baseURL: 'https://api.clore.ai/v1', // (optional) Override the default base URL for the API
  fetchOptions: {}, // (optional) Additional `RequestInit` options to be passed to `fetch` calls
  fetch: globalThis.fetch, // (optional) Specify a custom `fetch` function implementation
  queueOptions: {}, // (optional) Queue instance options https://github.com/sindresorhus/p-queue
  queueCreateOrderOptions: {}, // (optional) Create order queue instance options https://github.com/sindresorhus/p-queue
})

1. wallets

const wallets = await cloreai.wallets()

2. my_servers

const myServers = await cloreai.myServers()

3. server_config

const serverConfig = await cloreai.serverConfig({
  server_name: 'SERVER_NAME',
})

4. marketplace

const marketplace = await cloreai.marketplace()

5. my_orders

const myOrders = await cloreai.myOrders() // Current orders
const allMyOrders = await cloreai.myOrders({ return_completed: true }) // All orders

6. spot_marketplace

const spotMarketplace = await cloreai.spotMarketplace({
  market: 6718, // Server id
})

7. set_server_settings

await cloreai.setServerSettings({
  'name': 'NAME', // Server name
  'availability': true,
  'mrl': 24,
  'bitcoin_on_demand': 1,
  'bitcoin_spot': 1,
  'CLORE-Blockchain_on_demand': 1,
  'CLORE-Blockchain_spot': 1,
  'USD-Blockchain_on_demand': 1,
  'USD-Blockchain_spot': 1,
  'enabled-USD-Blockchain': true,
  'enabled-CLORE-Blockchain': true,
  'enabled-bitcoin': true,
  'autoprice': {
    'CLORE-Blockchain': 'usd',
    'USD-Blockchain': 'usd',
    'bitcoin': 'usd',
  },
  'usd_pricing': {
    'CLORE-Blockchain': { on_demand: 1, spot: 1 },
    'USD-Blockchain': { on_demand: 1, spot: 1 },
    'bitcoin': { on_demand: 1, spot: 1 },
  },
})

8. set_spot_price

await cloreai.setSpotPrice({
  order_id: 38176,
  desired_price: 50,
})

9. cancel_order

await cloreai.cancelOrder({
  id: 6718,
  issue: 'issue',
})

10. create_order

await cloreai.createOrder({
  type: 'on-demand',
  currency: 'CLORE-Blockchain',
  image: 'cloreai/jupyter:ubuntu24.04-v2',
  renting_server: 5738,
  ports: { 22: 'tcp', 8888: 'http' },
  env: { SSH_PASSWORD: 'SSH_PASSWORD', JUPYTER_TOKEN: 'JUPYTER_TOKEN' },
  jupyter_token: 'JUPYTER_TOKEN',
  ssh_password: 'SSH_PASSWORD',
  required_price: 50,
  remember_password: true,
})

11. poh_balance

const pohBalance = await cloreai.pohBalance()

12. renter_fees

const renterFees = await cloreai.renterFees()

GigaSPOT

getGigaspot

const gigaspot = await cloreai.gigaspot.getGigaspot()

createGigaspotOrders

import { gigaspotBaseImages } from 'cloreai'

await cloreai.gigaspot.createGigaspotOrders([
  {
    currency: 'CLORE-Blockchain',
    image: gigaspotBaseImages.UBUNTU, // Use the base image constant
    renting_server: 5941,
    price: 50,
    oc: [
      {
        pl: 150,
      },
    ],
  },
])

editGigaspotOrders

await cloreai.gigaspot.editGigaspotOrders([
  {
    order_id: 58991,
    price: 50,
    oc: [
      {
        pl: 150,
      },
    ],
  },
])

cancelOrders

await cloreai.gigaspot.cancelOrders({
  order_ids: [8383],
})

Fetch Options

All methods accept fetch options as the last parameter, for example:

const marketplace = await cloreai.marketplace({
  // `RequestInit` options
})

Error Handling

Use the CloreaiError class for error handling.

Errors have fields with information error.statusCode and error.description.

Use the constant statusCodes to check the error type.

import { CloreaiError, statusCodes } from 'cloreai'

try {
  const marketplace = await cloreai.marketplace()
} catch (error) {
  if (error instanceof CloreaiError) {
    console.log(error.statusCode, error.description)

    if (error.statusCode === statusCodes.EXCEEDED) {
      console.log('Rate limit exceeded error')
    }
  } else {
    throw error
  }
}

Rate limit

All methods are protected from rate limit exceeded through p-queue, they automatically delay for the needed time to avoid exceeding the limit.

Default rate limit values are available as constants:

import { RATE_LIMIT, RATE_LIMIT_CREATE_ORDER } from 'cloreai'

console.log(RATE_LIMIT)
console.log(RATE_LIMIT_CREATE_ORDER)

You can set your own rate limit values for each request queue:

const cloreai = new Cloreai('API_KEY', {
  queueOptions: {
    interval: 2000, // For example 2 seconds
  },
  queueCreateOrderOptions: {
    interval: 6000, // For example 6 seconds
  },
})

Access to p-queue instances:

  • cloreai.queue - main request queue
  • cloreai.queueCreateOrder - createOrder request queue

Retries

For retrying, it's recommended to use p-retry:

import pRetry from 'p-retry'

const marketplace = await pRetry(
  async () => {
    return await cloreai.marketplace()
  },
  {
    retries: 5,
  },
)

Timeouts

Use AbortSignal.timeout:

const marketplace = await cloreai.marketplace({
  signal: AbortSignal.timeout(5000),
})

Combine signals using AbortSignal.any. In the following example, the request will be aborted after 5 seconds, but can also be aborted earlier by calling controller.abort():

const controller = new AbortController()

// You can abort by event
// controller.abort()

const marketplace = await cloreai.marketplace({
  signal: AbortSignal.any([AbortSignal.timeout(5000), controller.signal]),
})