{"_id":"@buzhijie/midjourney","_rev":"1-43c42132a7eb3197b1d78f6c3f6c5942","name":"@buzhijie/midjourney","dist-tags":{"latest":"4.0.1"},"versions":{"4.0.0":{"name":"@buzhijie/midjourney","version":"4.0.0","description":"Node.js client for the unofficial MidJourney API.","main":"libs/index.js","types":"libs/index.d.ts","source":"./src/index.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","prettier":"prettier --write .","prettier:check":"prettier --check .","example:imagine":"tsx ./examples/imagine-ws.ts"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"repository":{"type":"git","url":"git+https://github.com/erictik/midjourney-client.git"},"keywords":["midjourney-client","midjourney"],"engines":{"node":">=18"},"author":{"name":"Eric Yang","email":"yanghao@10d.xin"},"license":"ISC","bugs":{"url":"https://github.com/erictik/midjourney-client/issues"},"homepage":"https://github.com/erictik/midjourney-client#readme","devDependencies":{"@types/async":"^3.2.20","@types/node":"^18.16.0","@types/ws":"^8.5.4","dotenv":"^16.0.3","prettier":"^2.8.8","ts-node":"^10.9.1","tsx":"^3.12.6","typescript":"^5.0.4"},"dependencies":{"@huggingface/inference":"^2.5.0","async":"^3.2.4","axios-https-proxy-fix":"^0.17.1","http-proxy-agent":"^7.0.2","isomorphic-ws":"^5.0.0","midjourney":"^4.3.17","node-fetch":"^3.3.2","semiver":"^1.1.0","snowyflake":"^2.0.0","socks-proxy-agent":"^8.0.2","tslib":"^2.5.0","undici":"^6.9.0","ws":"^8.13.0"},"gitHead":"1346be21baa852938e5eaed4329bf72f2c45e8aa","_id":"@buzhijie/midjourney@4.0.0","_nodeVersion":"21.7.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-c49UR5NSEjhYkHZLitiDW2JfjMy/TJietHUxfF3DFfXryesztMz28kqGE7LIEjqF7tBZp/KuRWLJmIz331Q88g==","shasum":"9c38bd86f2e6d34c5ceb1353affaaee3e0634850","tarball":"https://registry.npmjs.org/@buzhijie/midjourney/-/midjourney-4.0.0.tgz","fileCount":24,"unpackedSize":140994,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICRkUHVfHTPnV0lfqaUeBIfmzwqn79HrOx8+BH1Lf6LNAiEAtx2dDKUFVyHvRfnlVGLGuv1BahOk0CnEowckknL6Cz8="}]},"_npmUser":{"name":"buzhijie","email":"315336109@qq.com"},"directories":{},"maintainers":[{"name":"buzhijie","email":"315336109@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/midjourney_4.0.0_1711003352690_0.8340342300117867"},"_hasShrinkwrap":false},"4.0.1":{"name":"@buzhijie/midjourney","version":"4.0.1","description":"Node.js client for the unofficial MidJourney API.","main":"libs/index.js","types":"libs/index.d.ts","source":"./src/index.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","prettier":"prettier --write .","prettier:check":"prettier --check .","example:imagine":"tsx ./examples/imagine-ws.ts"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"repository":{"type":"git","url":"git+https://github.com/erictik/midjourney-client.git"},"keywords":["midjourney-client","midjourney"],"engines":{"node":">=18"},"author":{"name":"Eric Yang","email":"yanghao@10d.xin"},"license":"ISC","bugs":{"url":"https://github.com/erictik/midjourney-client/issues"},"homepage":"https://github.com/erictik/midjourney-client#readme","devDependencies":{"@types/async":"^3.2.20","@types/node":"^18.16.0","@types/ws":"^8.5.4","dotenv":"^16.0.3","prettier":"^2.8.8","ts-node":"^10.9.1","tsx":"^3.12.6","typescript":"^5.0.4"},"dependencies":{"@huggingface/inference":"^2.5.0","async":"^3.2.4","axios-https-proxy-fix":"^0.17.1","http-proxy-agent":"^7.0.2","isomorphic-ws":"^5.0.0","midjourney":"^4.3.17","node-fetch":"^3.3.2","semiver":"^1.1.0","snowyflake":"^2.0.0","socks-proxy-agent":"^8.0.2","tslib":"^2.5.0","undici":"^6.9.0","ws":"^8.13.0"},"gitHead":"1346be21baa852938e5eaed4329bf72f2c45e8aa","_id":"@buzhijie/midjourney@4.0.1","_nodeVersion":"21.7.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-npxXONS7Yog0xYU77dml3JRGbOAifMkvrtoxhTzN7Zy73g7rJVDc0/QE0ugxHap3XFesXZGpWtpB/cRgJuevzQ==","shasum":"eb5eb5d84ee07706d42cf04d2e0ff614345ac0bb","tarball":"https://registry.npmjs.org/@buzhijie/midjourney/-/midjourney-4.0.1.tgz","fileCount":81,"unpackedSize":377157,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFbO6nZi2FcviaZEgvpk9rz3tQD6ctvZKgqshovbp+u0AiEAz309HyEBIQ+uO/zGMTsZdm/UyPGFDLCSQAtErXqXjxs="}]},"_npmUser":{"name":"buzhijie","email":"315336109@qq.com"},"directories":{},"maintainers":[{"name":"buzhijie","email":"315336109@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/midjourney_4.0.1_1711004121746_0.5008685088264495"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-21T06:42:32.577Z","4.0.0":"2024-03-21T06:42:32.874Z","modified":"2024-03-21T06:55:22.336Z","4.0.1":"2024-03-21T06:55:21.936Z"},"maintainers":[{"name":"buzhijie","email":"315336109@qq.com"}],"description":"Node.js client for the unofficial MidJourney API.","homepage":"https://github.com/erictik/midjourney-client#readme","keywords":["midjourney-client","midjourney"],"repository":{"type":"git","url":"git+https://github.com/erictik/midjourney-client.git"},"author":{"name":"Eric Yang","email":"yanghao@10d.xin"},"bugs":{"url":"https://github.com/erictik/midjourney-client/issues"},"license":"ISC","readme":"# midjourney-client\n\nNode.js client for the unofficial MidJourney api.\n\nEnglish / [中文文档](README_zh.md)\n\n<div align=\"center\">\n\t<p>\n\t\t<a href=\"https://discord.gg/GavuGHQbV4\"><img src=\"https://img.shields.io/discord/1082500871478329374?color=5865F2&logo=discord&logoColor=white\" alt=\"Discord server\" /></a>\n\t\t<a href=\"https://www.npmjs.com/package/midjourney\"><img src=\"https://img.shields.io/npm/v/midjourney.svg?maxAge=3600\" alt=\"npm version\" /></a>\n\t</p>\n</div>\n\n## What's new\n\n- [face swap](https://github.com/erictik/midjourney-client/blob/main/example/faceswap.ts)\n- [niji bot](https://github.com/erictik/midjourney-client/blob/main/example/imagine-niji.ts)\n- [custom zoom](https://github.com/erictik/midjourney-client/blob/main/example/customzoom.ts)\n- [remix mode](https://github.com/erictik/midjourney-client/blob/main/example/variation-ws.ts)\n\n## Example\n\nTo run the included example, you must have [Node.js](https://nodejs.org/en/) installed. Then, run the following commands in the root directory of this project:\n\n1. clone the repository\n\n   ```bash\n   git clone https://github.com/erictik/midjourney-client.git\n   cd midjourney-client\n   ```\n\n2. install dependencies\n\n   ```bash\n   yarn\n   # or npm\n   npm install\n   ```\n\n3. set the environment variables\n\n- [Login Discord](https://discord.com/channels/@me)`F12` _OR_ `Ctrl + Shift + I` (or `Command + Option + I` on Mac) to open the developer tools _AND_ paste the following code into the console\n\n  ```javascript\n  window.webpackChunkdiscord_app.push([\n    [Math.random()],\n    {},\n    (req) => {\n      for (const m of Object.keys(req.c)\n        .map((x) => req.c[x].exports)\n        .filter((x) => x)) {\n        if (m.default && m.default.getToken !== undefined) {\n          return copy(m.default.getToken());\n        }\n        if (m.getToken !== undefined) {\n          return copy(m.getToken());\n        }\n      }\n    },\n  ]);\n  console.log(\"%cWorked!\", \"font-size: 50px\");\n  console.log(`%cYou now have your token in the clipboard!`, \"font-size: 16px\");\n  ```\n\n  OR [use network your Discord TOKEN](https://www.androidauthority.com/get-discord-token-3149920/)\n\n- [Join my discord server](https://discord.com/invite/GavuGHQbV4)\n\n  ```\n  export SERVER_ID=\"1082500871478329374\"\n  export CHANNEL_ID=\"1094892992281718894\"\n  ```\n\n- OR [Create a server](https://discord.com/blog/starting-your-first-discord-server) and [Invite Midjourney Bot to Your Server](https://docs.midjourney.com/docs/invite-the-bot)\n\n  ```bash\n  # How to get server and channel ids:\n  # when you click on a channel in your server in the browser\n  # expect to have the follow URL pattern\n  # `https://discord.com/channels/$SERVER_ID/$CHANNEL_ID`\n  export SERVER_ID=\"your-server-id\"\n  export CHANNEL_ID=\"your-channel-id\"\n  ```\n\n- wirte your token to `.env` file or set the environment variables\n\n  ```bash\n    #example variables, please set up yours\n\n    export SERVER_ID=\"1082500871478329374\"\n    export CHANNEL_ID=\"1094892992281718894\"\n    export SALAI_TOKEN=\"your-discord-token\"\n  ```\n\n- Then, run the example with the following command:\n\n  ```bash\n  npx tsx example/imagine-ws.ts\n  ```\n\n  OR\n\n  ```bash\n  yarn example:imagine\n  # or npm\n  npm run example:imagine\n  ```\n\n- [more example](./example/)\n\n## Usage\n\n1. Install\n\n   ```bash\n   npm i midjourney\n   # or\n   yarn add midjourney\n   ```\n\n2. config param\n   ```typescript\n   export interface MJConfigParam {\n     SalaiToken: string; //DISCORD_TOKEN\n     ChannelId?: string; //DISCORD_CHANNEL_ID\n     ServerId?: string; //DISCORD_SERVER_ID\n     BotId?: typeof MJBot | typeof NijiBot; //DISCORD_BOT_ID MJBot OR NijiBot\n     Debug?: boolean; // print log\n     ApiInterval?: number; //ApiInterval request api interval\n     Limit?: number; //Limit of get message list\n     MaxWait?: number;\n     Remix?: boolean; //Remix:true use remix mode\n     Ws?: boolean; //Ws:true use websocket get discord message (ephemeral message)\n     HuggingFaceToken?: string; //HuggingFaceToken for verify human\n     SessionId?: string;\n     DiscordBaseUrl?: string;\n     ImageProxy?: string;\n     WsBaseUrl?: string;\n     fetch?: FetchFn; //Node.js<18 need node.fetch Or proxy\n     WebSocket?: WebSocketCl; //isomorphic-ws Or proxy\n   }\n   ```\n3. Use Imagine 、Variation and Upscale\n\n   ```typescript\n   import { Midjourney } from \"midjourney\";\n   const client = new Midjourney({\n     ServerId: <string>process.env.SERVER_ID,\n     ChannelId: <string>process.env.CHANNEL_ID,\n     SalaiToken: <string>process.env.SALAI_TOKEN,\n     Debug: true,\n     Ws: true, //enable ws is required for remix mode (and custom zoom)\n   });\n   await client.init();\n   const prompt =\n     \"Christmas dinner with spaghetti with family in a cozy house, we see interior details , simple blue&white illustration\";\n   //imagine\n   const Imagine = await client.Imagine(\n     prompt,\n     (uri: string, progress: string) => {\n       console.log(\"loading\", uri, \"progress\", progress);\n     }\n   );\n   console.log(Imagine);\n   if (!Imagine) {\n     console.log(\"no message\");\n     return;\n   }\n   //U1 U2 U3 U4 V1 V2 V3 V4  \"Vary (Strong)\" ...\n   //⬅️,⬆️,⬇️,➡️\n   const V1CustomID = Imagine.options?.find((o) => o.label === \"V1\")?.custom;\n   if (!V1CustomID) {\n     console.log(\"no V1\");\n     return;\n   }\n   // Varition V1\n   const Varition = await client.Custom({\n     msgId: <string>Imagine.id,\n     flags: Imagine.flags,\n     customId: V1CustomID,\n     content: prompt, //remix mode require content\n     loading: (uri: string, progress: string) => {\n       console.log(\"loading\", uri, \"progress\", progress);\n     },\n   });\n   console.log(Varition);\n   const U1CustomID = Imagine.options?.find((o) => o.label === \"U1\")?.custom;\n   if (!U1CustomID) {\n     console.log(\"no U1\");\n     return;\n   }\n   // Upscale U1\n   const Upscale = await client.Custom({\n     msgId: <string>Imagine.id,\n     flags: Imagine.flags,\n     customId: U1CustomID,\n     loading: (uri: string, progress: string) => {\n       console.log(\"loading\", uri, \"progress\", progress);\n     },\n   });\n   if (!Upscale) {\n     console.log(\"no Upscale\");\n     return;\n   }\n   console.log(Upscale);\n   const zoomout = Upscale?.options?.find((o) => o.label === \"Custom Zoom\");\n   if (!zoomout) {\n     console.log(\"no zoomout\");\n     return;\n   }\n   // Custom Zoom\n   const CustomZoomout = await client.Custom({\n     msgId: <string>Upscale.id,\n     flags: Upscale.flags,\n     content: `${prompt} --zoom 2`, // Custom Zoom  require content\n     customId: zoomout.custom,\n     loading: (uri: string, progress: string) => {\n       console.log(\"loading\", uri, \"progress\", progress);\n     },\n   });\n   console.log(CustomZoomout);\n   ```\n\n\n\n## route-map\n\n- [x] `/imagine` `variation` `upscale` `reroll` `blend` `zoomout` `vary`\n- [x] `/info`\n- [x] `/fast ` and `/relax `\n- [x] [`/prefer remix`](https://github.com/erictik/midjourney-client/blob/main/example/prefer-remix.ts)\n- [x] [`variation (remix mode)`](https://github.com/erictik/midjourney-client/blob/main/example/variation-ws.ts)\n- [x] `/describe`\n- [x] [`/shorten`](https://github.com/erictik/midjourney-client/blob/main/example/shorten.ts)\n- [x] `/settings` `reset`\n- [x] verify human\n- [x] [proxy](https://github.com/erictik/midjourney-discord/blob/main/examples/proxy.ts)\n- [x] [niji bot](https://github.com/erictik/midjourney-client/blob/main/example/imagine-niji.ts)\n- [x] [custom zoom](https://github.com/erictik/midjourney-client/blob/main/example/customzoom.ts)\n- [x] autoload command payload\n\n---\n\n## Projects\n\n- [midjourney-ui](https://github.com/erictik/midjourney-ui/) next.js + vercel\n- [midjourney-discord](https://github.com/erictik/midjourney-discord)-bot\n- [phrame](https://github.com/jakowenko/phrame)\n- [guapitu](https://www.guapitu.com/zh/draw?code=RRXQNF)\n\n---\n\n## Support\n\nIf you find it valuable and would like to show your support, any donations would be greatly appreciated. Your contribution helps me maintain and improve the program.\n\n<span style=\"word-spacing:20px\">\n<img src=\"images/ali.png\" height=\"300\"/>  \n<img src=\"images/wechat.png\" height=\"300\"/>\n<a href='https://ko-fi.com/erictik' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi1.png?v=3' border='0' alt='Buy Me a Coffee' /></a>\n</span>\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=erictik/midjourney-client&type=Date)](https://star-history.com/#erictik/midjourney-client&Date)\n","readmeFilename":"README.md"}