{"id":20674905,"url":"https://github.com/cheshire-cat-ai/api-client-ts","last_synced_at":"2025-04-19T20:33:57.627Z","repository":{"id":176544883,"uuid":"658145916","full_name":"cheshire-cat-ai/api-client-ts","owner":"cheshire-cat-ai","description":"API Client to communicate with the Cheshire Cat AI","archived":false,"fork":false,"pushed_at":"2025-01-22T15:17:48.000Z","size":433,"stargazers_count":19,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-16T09:02:02.554Z","etag":null,"topics":["api","api-client","cat","cheshire-cat","client","generator","javascript","llm","npm","openapi","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/ccat-api","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cheshire-cat-ai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-24T23:11:26.000Z","updated_at":"2025-03-03T18:04:04.000Z","dependencies_parsed_at":"2023-10-21T09:28:20.137Z","dependency_job_id":"14ce64b3-876e-4f8a-847c-6593dbd9a16e","html_url":"https://github.com/cheshire-cat-ai/api-client-ts","commit_stats":null,"previous_names":["zalweny26/ccat-api","cheshire-cat-ai/api-client-ts"],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheshire-cat-ai%2Fapi-client-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheshire-cat-ai%2Fapi-client-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheshire-cat-ai%2Fapi-client-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheshire-cat-ai%2Fapi-client-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cheshire-cat-ai","download_url":"https://codeload.github.com/cheshire-cat-ai/api-client-ts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249794853,"owners_count":21326775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-client","cat","cheshire-cat","client","generator","javascript","llm","npm","openapi","typescript"],"created_at":"2024-11-16T21:08:03.341Z","updated_at":"2025-04-19T20:33:57.591Z","avatar_url":"https://github.com/cheshire-cat-ai.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://github.com/cheshire-cat-ai/api-client-ts\"\u003e\n  \u003cimg alt=\"GitHub Stars\" src=\"https://img.shields.io/github/stars/cheshire-cat-ai/api-client-ts?logo=github\u0026style=flat-square\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://discord.gg/bHX5sNFCYU\"\u003e\n  \u003cimg alt=\"Discord Server\" src=\"https://img.shields.io/discord/1092359754917089350?logo=discord\u0026style=flat-square\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://npmjs.com/package/ccat-api\"\u003e\n  \u003cimg alt=\"NPM Version\" src=\"https://img.shields.io/npm/v/ccat-api?logo=npm\u0026style=flat-square\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://npmjs.com/package/ccat-api\"\u003e\n  \u003cimg alt=\"NPM Downloads\" src=\"https://img.shields.io/npm/dw/ccat-api?logo=npm\u0026style=flat-square\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://bundlephobia.com/package/ccat-api\"\u003e\n  \u003cimg alt=\"Bundle Size\" src=\"https://img.shields.io/bundlephobia/minzip/ccat-api?logo=npm\u0026style=flat-square\"\u003e\n\u003c/a\u003e\n\n# Cheshire Cat AI API Client\n\nAPI Client made in TypeScript to communicate with the [Cheshire Cat AI](https://github.com/cheshire-cat-ai/core).\\\nThe package provides a class to interface with the Cheshire Cat AI backend.\\\nIt can be used both in Browser and NodeJS environments.\n\nEvery endpoint is a `CancelablePromise`, which means you can cancel the request if you want.\n\n## Installation\n\n```bash\nnpm i ccat-api\n# OR\nyarn add ccat-api\n# OR\npnpm i ccat-api\n# OR\nbun i ccat-api\n```\n\n## Getting started\n\nTo set up the client, you must first import the `CatClient` class:\n\n```ts\nimport { CatClient } from 'ccat-api'\n\nconst cat = new CatClient({\n    host: 'localhost',\n    userId: 'user',\n    //... other settings\n})\n\ncat.send('Hello from a user!') // this will send a message to the /ws/user\n\ncat.userId = 'new_user'\n\ncat.send('Hello from a new user!') // this will send a message to the /ws/new_user\n```\n\n## Client settings\n\n**CCAT_API_KEY**, **CCAT_CORE_HOST**, **CCAT_CORE_PORT** and **CCAT_CORE_USE_SECURE_PROTOCOLS** refer to the CCAT Core [.env file](https://github.com/cheshire-cat-ai/core/blob/main/.env.example).\n\n| **Property**   | **Type** | **Default**  | **Description**                                                                  |\n|:--------------:|:--------:|:------------:|:--------------------------------------------------------------------------------:|\n| **host**       | string   | **Required** | The same of **CCAT_CORE_HOST**                                                   |\n| **credential** | string   | undefined    | The same of **CCAT_API_KEY** or the JWT token                                    |\n| **port**       | number   | 1865         | The same of the **CCAT_CORE_PORT**                                               |\n| **secure**     | boolean  | false        | The same of the **CCAT_CORE_USE_SECURE_PROTOCOLS**                               |\n| **user**       | string   | 'user'       | The user ID to use for the WebSocket and the API client                          |\n| **instant**    | boolean  | true         | Instantly initialize the WebSocket and the API client, or later with **.init()** |\n| **timeout**    | number   | 10000        | Timeout for the endpoints, in milliseconds                                       |\n| **ws**         | string   | undefined    | An object of type [WebSocketSettings](#websocket-settings)                       |\n\n### WebSocket settings\n\n| **Property** | **Type** | **Default** | **Description**                                           |\n|:------------:|:--------:|:-----------:|:---------------------------------------------------------:|\n| **retries**  | number   | 3           | The maximum number of retries before calling **onFailed** |\n| **delay**    | number   | 3000        | The delay for reconnect, in milliseconds                  |\n| **onFailed** | function | undefined   | The function to call after failing all the retries        |\n\nThen, for example, you can configure the LLM like this:\n\n```ts\ncat.api.llm.upsertLlmSetting('LLMOpenAIConfig', {\n    openai_api_key: 'OPEN_API_KEY'\n})\n```\n\nTo send a message to the cat, you can:\n\n```ts\ncat.send('Hello my friend!')\n```\n\nYou can listen to the WebSocket events:\n\n```ts\ncat.onConnected(() =\u003e {\n    console.log('Socket connected')\n}).onMessage(msg =\u003e {\n    console.log(msg)\n}).onError((err, e) =\u003e {\n    console.error(err, e)\n}).onDisconnected(() =\u003e {\n    console.log('Socket disconnected')\n})\n```\n\nFor example, you can get the list of plugins like this:\n\n```ts\ncat.api.plugins.listAvailablePlugins().then(plugins =\u003e {\n    console.log(plugins)\n})\n```\n\n## Credits\n\nMade for the [Cheshire Cat AI](https://github.com/cheshire-cat-ai) organization.\n\nThis was possible thanks to [openapi-typescript-codegen](https://github.com/ferdikoomen/openapi-typescript-codegen).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheshire-cat-ai%2Fapi-client-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheshire-cat-ai%2Fapi-client-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheshire-cat-ai%2Fapi-client-ts/lists"}