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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@parking-master/node_characterai

v1.0.2

Published

An unofficial API wrapper for Character.AI. Works in Node.js using WebSocket requests.

Downloads

11

Readme

characterai

An unofficial API wrapper for Character.AI. Works in Node.js using WebSocket requests.

Install

First install it using NPM:

$ npm install @parking-master/node_characterai

Then continue with the rest of the documentation.

Quick start

There are only three steps to set up this API:

  • Authenticate your account
  • Set up your character
  • Send a message

Get all the required info

All the required info you need is: Your HTTP token, author id, author name, character id, and chat id.

To get this info, go to your character's chat page and open the web console using Ctrl/Cmd+Shift/Alt+I.

Make sure you're on another chat page, not the default. For example, the URL should show "/chat2?char=..." instead of "/chat?char=...".

Then reload the page.

Then, go to the Network tab, reload the page, search for "ws" and click on the neo.character.ai request. This is where all the info is. Send a message to your character to show the info.

Then do the following steps to get the info you need.

Authenticate

Go to Cookies, and go to the root URL. Then, in the tables show all the cookies in the console, find the cookie "HTTP_AUTHORIZATION". The part after "Token ..." is your auth token. Copy this.

Character ID

The character's ID is shown in the URL of the chat page. The "char" parameter contains the id. For example:

https://beta.character.ai/chat2?char=6HhWfeDjetnxESEcThlBQtEUo0O8YHcXyHqCgN7b2hY

"6HhWfeDjetnxESEcThlBQtEUo0O8YHcXyHqCgN7b2hY" is the chaarcter ID.

Chat ID

Send a message to your character and the info will be displayed in the console. Grab the value of "chat_id" and you're good to go.

Author ID

Still in the console, when you sent the message, find "author_id" and get the value as a number.

Author name

The Author name will just be your profile username. Copy that as well.

Setup the API

Now, if you have all the info, you can set up the API.

First authenticate your account by doing this:

characterAI.authenticate(YOUR_AUTH_TOKEN);
characterAI.setup(CHARACTER_ID, CHAT_ID, AUTHOR_ID, AUTHOR_NAME);

Replace all the required fields with your info.

Now, you can send a message:

(async () => {
  let response = await characterAI.send("Hello!");
  console.log(response);
})();

Example

Here's a full example that has been tested and works:

const characterAI = require("@parking-master/node_characterai");

characterAI.authenticate("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
characterAI.setup("6HhWfeDjetnxESEcThlBQtEUo0O8YHcXyHqCgN7b2hY", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", 18378286, "myname123");

(async () => {
  let response = await characterAI.send("Testing...");
  console.log(response);
})();

License

MIT