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

@codewords/client

v0.1.6

Published

Client for interacting with the CodeWords platform using CODEWORDS_API_KEY. Checkout docs.codewords.ai for more information.

Downloads

90

Readme

CodeWords Client

A TypeScript client for interacting with the CodeWords runtime API.

Usage

Basic Usage

import { createServiceClient } from "@codewords/client";

// Create a client instance with a standard API key or one-time API key
const client = createServiceClient("cwk-your-api-key");
const client = createServiceClient("cwotk-your-one-time-key");

// Run a service
async function runExample() {
  const result = await client.runService("service-id", "path", {
    // request body
    key: "value",
  });
  console.log(result);
}

API Key Types

The client supports two types of API keys:

  1. Standard API Keys (prefix: cwk-): Persistent keys that can be used multiple times
  2. One-Time API Keys (prefix: cwotk-): Keys that are invalidated after a single use
// Using a standard API key
const standardClient = createServiceClient("cwk-your-api-key");

// Using a one-time API key
const oneTimeClient = createServiceClient("cwotk-your-one-time-key");

// Check the type of key being used
import { ApiKeyType } from "@codewords/client";

if (client.getApiKeyType() === ApiKeyType.ONE_TIME) {
  console.log("Using a one-time key that will be invalidated after use");
}

Streaming Logs

You'd need to have started a run before you can stream logs.

// Stream logs for a request
for await (const logLine of client.streamLogs(request_id)) {
  console.log(logLine);
}

File Uploads

// Method 1: Create upload/download URLs
const { upload_uri, download_uri } =
  await client.createFileUpload("example.txt");
await client.uploadFile(upload_uri, Buffer.from("Hello, world!"));
console.log("File available at:", download_uri);

// Method 2: Simplified helper method
const downloadUrl = await client.uploadFileAndGetUrl(
  "example.txt",
  Buffer.from("Hello, world!")
);
console.log("File available at:", downloadUrl);

Getting Request Details

// Get details for a completed request
const details = await client.getRequestDetails(request_id);
console.log("Request completed at:", details.completedAt);
console.log("Response:", details.responseContent);

API Reference

Constructor

new ServiceClient(apiKey: string)
  • apiKey: Your API key for authentication (can be a standard key 'cwk-' or one-time key 'cwotk-')

Methods

  • getApiKeyType(): ApiKeyType - Get the type of API key being used
  • runService<T>(serviceId: string, path?: string, body?: any, requestId?: string, correlationId?: string, queryParams?: string): Promise<T>
  • streamLogs(requestId: string): AsyncGenerator<string>
  • createFileUpload(filename: string): Promise<UploadDownloadLinks>
  • uploadFile(uploadUrl: string, file: any): Promise<AxiosResponse>
  • provisionRequest(): Promise<ProvisionedRequestResponse>
  • getRequestDetails(requestId: string): Promise<RequestDetails>
  • uploadFileAndGetUrl(filename: string, file: any): Promise<string>

Types

enum ApiKeyType {
  STANDARD = "STANDARD", // Regular API key (cwk-)
  ONE_TIME = "ONE_TIME", // One-time API key (cwotk-)
  UNKNOWN = "UNKNOWN", // Unknown key format
}

interface UploadDownloadLinks {
  upload_uri: string;
  download_uri: string;
}

interface ProvisionedRequestResponse {
  request_id: string;
}

interface RequestDetails {
  id: string;
  userId: string;
  serviceId?: string;
  createdAt: string;
  startedAt?: string;
  completedAt?: string;
  responseStatus?: number;
  responseContent?: string;
  responseJson?: any;
}