{"id":13454977,"url":"https://github.com/erictik/midjourney-api","last_synced_at":"2025-05-14T23:06:40.975Z","repository":{"id":154405438,"uuid":"631998225","full_name":"erictik/midjourney-api","owner":"erictik","description":"MidJourney client. Unofficial Node.js client","archived":false,"fork":false,"pushed_at":"2025-05-07T02:48:09.000Z","size":2802,"stargazers_count":1794,"open_issues_count":123,"forks_count":295,"subscribers_count":26,"default_branch":"main","last_synced_at":"2025-05-14T23:06:22.783Z","etag":null,"topics":["midjourney","midjourney-client"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erictik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"ko_fi":"erictik"}},"created_at":"2023-04-24T13:54:42.000Z","updated_at":"2025-05-14T12:59:35.000Z","dependencies_parsed_at":"2024-01-13T17:33:17.048Z","dependency_job_id":"a3065111-e093-461e-a0e2-3d8c75a15637","html_url":"https://github.com/erictik/midjourney-api","commit_stats":null,"previous_names":["erictik/midjourney-client"],"tags_count":120,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erictik%2Fmidjourney-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erictik%2Fmidjourney-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erictik%2Fmidjourney-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erictik%2Fmidjourney-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erictik","download_url":"https://codeload.github.com/erictik/midjourney-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254243362,"owners_count":22038046,"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":["midjourney","midjourney-client"],"created_at":"2024-07-31T08:00:59.969Z","updated_at":"2025-05-14T23:06:35.956Z","avatar_url":"https://github.com/erictik.png","language":"TypeScript","funding_links":["https://ko-fi.com/erictik","https://ko-fi.com/erictik'"],"categories":["TypeScript","Tools \u0026 Services","📦 Legacy \u0026 Inactive Projects"],"sub_categories":["Individual Episodes"],"readme":"# midjourney-client\n\nNode.js client for the unofficial MidJourney api.\n\nEnglish / [中文文档](README_zh.md)\n\n\u003cdiv align=\"center\"\u003e\n\t\u003cp\u003e\n\t\t\u003ca href=\"https://discord.gg/GavuGHQbV4\"\u003e\u003cimg src=\"https://img.shields.io/discord/1082500871478329374?color=5865F2\u0026logo=discord\u0026logoColor=white\" alt=\"Discord server\" /\u003e\u003c/a\u003e\n\t\t\u003ca href=\"https://www.npmjs.com/package/midjourney\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/midjourney.svg?maxAge=3600\" alt=\"npm version\" /\u003e\u003c/a\u003e\n\t\u003c/p\u003e\n\u003c/div\u003e\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) =\u003e {\n      for (const m of Object.keys(req.c)\n        .map((x) =\u003e req.c[x].exports)\n        .filter((x) =\u003e x)) {\n        if (m.default \u0026\u0026 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\u003c18 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: \u003cstring\u003eprocess.env.SERVER_ID,\n     ChannelId: \u003cstring\u003eprocess.env.CHANNEL_ID,\n     SalaiToken: \u003cstring\u003eprocess.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\u0026white illustration\";\n   //imagine\n   const Imagine = await client.Imagine(\n     prompt,\n     (uri: string, progress: string) =\u003e {\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) =\u003e 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: \u003cstring\u003eImagine.id,\n     flags: Imagine.flags,\n     customId: V1CustomID,\n     content: prompt, //remix mode require content\n     loading: (uri: string, progress: string) =\u003e {\n       console.log(\"loading\", uri, \"progress\", progress);\n     },\n   });\n   console.log(Varition);\n   const U1CustomID = Imagine.options?.find((o) =\u003e 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: \u003cstring\u003eImagine.id,\n     flags: Imagine.flags,\n     customId: U1CustomID,\n     loading: (uri: string, progress: string) =\u003e {\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) =\u003e 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: \u003cstring\u003eUpscale.id,\n     flags: Upscale.flags,\n     content: `${prompt} --zoom 2`, // Custom Zoom  require content\n     customId: zoomout.custom,\n     loading: (uri: string, progress: string) =\u003e {\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\u003cspan style=\"word-spacing:20px\"\u003e\n\u003cimg src=\"images/ali.png\" height=\"300\"/\u003e  \n\u003cimg src=\"images/wechat.png\" height=\"300\"/\u003e\n\u003ca href='https://ko-fi.com/erictik' target='_blank'\u003e\u003cimg 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' /\u003e\u003c/a\u003e\n\u003c/span\u003e\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=erictik/midjourney-client\u0026type=Date)](https://star-history.com/#erictik/midjourney-client\u0026Date)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferictik%2Fmidjourney-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferictik%2Fmidjourney-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferictik%2Fmidjourney-api/lists"}