
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@useapi/midjourney-api
Advanced tools
This package contains TypeScript client library for Midjourney API by useapi.net.
Quick demo.
npm install @useapi/midjourney-api
Midjourney /imagine command available via jobs/imagine API endpoint.
Midjourney upscale or create variations and enhance or modify button commands available via jobs/button API endpoint.
Midjourney /describe command available via jobs/describe API endpoint.
Midjourney /blend command available via jobs/blend API endpoint.
Use jobs/?jobid=jobid API endpoint to retrieve job results.
Postman collection.
Swagger OpenAPI documentation for generating server stubs and client SDKs.
You need to set up and configure the Midjourey Discord account as well as subscribe to useapi.net service before you can start using API. Setup instructions.
import {
createConfiguration,
DefaultApi,
ImagineResponse,
ButtonResponse,
BlendResponse,
JobResponse,
JobsButtonPostRequestButtonEnum,
JobsBlendPostRequestBlendDimensionsEnum,
DescribeResponse,
} from '@useapi/midjourney-api';
const sleep = (ms = 0) => new Promise(resolve => setTimeout(resolve, ms));
const configuration = createConfiguration({
authMethods: {
apiToken: {
tokenProvider: {
// Load api token from environment
getToken() { return process.env.USEAPI_TOKEN ?? 'useapi.net API token' }
}
}
}
});
// Load Discord settings from environment
const discord = process.env.USEAPI_DISCORD ?? 'Discord token';
const server = process.env.USEAPI_SERVER ?? 'Discord server id number';
const channel = process.env.USEAPI_CHANNEL ?? 'Discord channel id number';
const apiInstance = new DefaultApi(configuration);
// Helper function to monitor job status and retrieve results
const waitForJobToComplete = async (
job: ImagineResponse |
ButtonResponse |
BlendResponse |
DescribeResponse |
JobResponse) => {
const verb = job.verb.toUpperCase();
console.log(`${verb} : ${job.status}`, job.jobid);
while (job.code == 200 && ['started', 'progress'].includes(job.status)) {
await sleep(20 * 1000);
// JobResponse
job = await apiInstance.jobsGet(job.jobid);
console.log(`${verb} : ${job.status}`, { jobid: job.jobid, content: job.content });
}
if ((job instanceof JobResponse) && job.attachments?.length)
console.log(`${verb} url`, job.attachments?.at(0)?.url);
if ((job instanceof JobResponse) && job.buttons?.length)
console.log(`${verb} buttons`, job.buttons?.join());
return job;
}
const demo = async () => {
// Midjourney /describe, using Promise pattern
apiInstance.jobsDescribePost(
{
describeUrl: "https://mymodernmet.com/wp/wp-content/uploads/2017/12/free-images-national-gallery-of-art-9.jpg",
discord,
server,
channel,
}
).then(async (data: DescribeResponse) => {
console.log('DESCRIBE started', data);
await waitForJobToComplete(data);
}).catch((error: any) => console.error('DESCRIBE failed', error));
// Midjourney /blend, using Promise pattern
apiInstance.jobsBlendPost(
{
blendUrls: [
"https://mymodernmet.com/wp/wp-content/uploads/2017/12/free-images-national-gallery-of-art-6.jpg",
"https://mymodernmet.com/wp/wp-content/uploads/2017/12/free-images-national-gallery-of-art-2.jpg"
],
blendDimensions: JobsBlendPostRequestBlendDimensionsEnum.Landscape,
discord,
server,
channel,
}
).then(async (data: BlendResponse) => {
console.log('BLEND started', data);
await waitForJobToComplete(data);
}).catch((error: any) => console.error('BLEND failed', error));
// Midjourney /imagine, using await & try..catch pattern
let job: ImagineResponse | JobResponse | ButtonResponse;
try {
// ImagineResponse
job = await apiInstance.jobsImaginePost(
{
prompt: "Steampunk cat cycling in San Francisco, vintage photo",
discord,
server,
channel,
});
await waitForJobToComplete(job);
const imagineJobId = job.jobid;
// Midjourney button, using await & try..catch pattern
job = await apiInstance.jobsButtonPost(
{
jobid: imagineJobId,
button: JobsButtonPostRequestButtonEnum.V1
});
await waitForJobToComplete(job);
} catch (ex: any) {
console.log('IMAGINE or BUTTON failed', ex);
}
}
demo();
Version 1.0.4 | November 3, 2023
Added support for following jobs/button options:
Visit our
FAQs
TypeScript client library for Midjourney API by useapi.net
The npm package @useapi/midjourney-api receives a total of 4,556 weekly downloads. As such, @useapi/midjourney-api popularity was classified as popular.
We found that @useapi/midjourney-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.