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

tnl-midjourney-api

v1.0.3

Published

A Node.js module for interacting with Midjourney via The Next Leg

Downloads

4,436

Readme

The Next Leg

The Next Leg is a module that provides functionality for creating AI-generated images with Midjourney. It provides a simple interface for interacting with Midjourney's API and performing various actions such as creating images from prompts or URLs, describing images, using buttons or slash commands, and getting account settings.

Installation

To use this module, you need to have Node.js installed on your machine. To install this module, run the following command:

npm install tnl-midjourney-api

Usage

Here is an example of how to use the module to create an image from a prompt:

import { TNL } from 'tnl-midjourney-api';

const TNL_API_KEY = 'your_api_key_here';
const tnl = new TNL(TNL_API_KEY);

const prompt = 'a cat playing the piano';
const response = await tnl.imagine(prompt);

console.log(response);

API

new TNL(apiKey: string)

Creates a new instance of TNL with the provided apiKey.

Imagine

tnl.imagine(prompt: string, ref?: string, webhookOverride?: string): Promise<TNLTypes.Response.Message>

Creates a new image from a prompt.

  • prompt - The prompt you want to use to generate the image.
  • ref (optional) - A reference string that will be returned in the webhook response.
  • webhookOverride (optional) - A webhook URL that will be used instead of the one set in the dashboard.

Get Progress and Message Result

tnl.getMessageAndProgress(messageId: string, expireMins?: number): Promise<TNLTypes.Response.MessageAndProgress>

Gets the progress and response of a message.

  • messageId - The message ID of the message you want to get the progress and response for.
  • expireMins (optional) - A timeout for the request in minutes. If the request takes longer than this, it will return as 'incomplete'

Img 2 Img

tnl.img2img(prompt: string, imgUrl: string, ref?: string, webhookOverride?: string): Promise<TNLTypes.Response.Message>

Creates an image from a prompt and an image.

  • prompt - The prompt you want to use to generate the image.
  • imgUrl - The URL of the image you want to use as the base image.
  • ref (optional) - A reference string that will be returned in the webhook response.
  • webhookOverride (optional) - A webhook URL that will be used instead of the one set in the dashboard.

Describe

tnl.describe(imgUrl: string, ref?: string, webhookOverride?: string): Promise<TNLTypes.Response.Message>

Describes an image.

  • imgUrl - The URL of the image you want to describe.
  • ref (optional) - A reference string that will be returned in the webhook response.
  • webhookOverride (optional) - A webhook URL that will be used instead of the one set in the dashboard.

Button

tnl.button(button: TNLTypes.ButtonTypes, buttonMessageId: string, ref?: string, webhookOverride?: string): Promise<TNLTypes.Response.Message>

Uses a button on an image.

  • button - A button type.
  • buttonMessageId - The buttonMessageId of the message that contains the button.
  • ref (optional) - A reference string that will be returned in the webhook response.
  • webhookOverride (optional) - A webhook URL that will be used instead of the one set in the dashboard.

Get Seed

tnl.getSeed(messageId: string): Promise<TNLTypes.Response.Seed>

Gets a seed of a message.

  • messageId - The message ID of the message you want to get the seed for.

Slash Command

tnl.slashCommand(slashCommand: TNLTypes.SlashCommands, ref?: string, webhookOverride?: string): Promise<TNLTypes.Response.Message>

Uses a slash command such as relax, fast, private, or stealth.

  • slashCommand - A slash command type.
  • ref (optional) - A reference string that will be returned in the webhook response.
  • webhookOverride (optional) - A webhook URL that will be used instead of the one set in the dashboard.

Get Settings

tnl.getSettings(): Promise<TNLTypes.Response.Message>

Gets the settings available for your account.

Set Settings

tnl.setSettings(settings: TNLTypes.Settings, ref?: string, webhookOverride?: string): Promise<TNLTypes.Response.Message>

Sets the settings for your account.

  • settings - The settings you want to set.
  • ref (optional) - A reference string that will be returned in the webhook response.
  • webhookOverride (optional) - A webhook URL that will be used instead of the one set in the dashboard.

Get Info

tnl.getInfo(ref?: string, webhookOverride?: string): Promise<TNLTypes.Response.Message>

Gets information about your account including Fast Time Remaining, Job Mode, Queued Jobs and more.

  • ref (optional) - A reference string that will be returned in the webhook response.
  • webhookOverride (optional) - A webhook URL that will be used instead of the one set in the dashboard.