Git Product home page Git Product logo

midjourney-web-api's Introduction

中文版本

Midjourney-Web-API

Unofficial Midjourney-Web-API, for learning and research purposes only.

✨ Features

  • ✨ Simple and easy to deploy
  • 👋 Support for caching images, mainland China access friendly
  • 💾 Support image Upscale function, get HD large image
  • 📚 Multi-threaded concurrency, high-speed drawing
  • 💻 Automatic database cleanup and error handling functions are perfect
  • 🔐 Cross-domain restrictions can be set, anti-theft

QuickStart fast start

  1. clone project
git clone https://github.com/CelestialRipple/Midjourney-Web-API
cd Midjourney-Web-API

2、 Get Cookie (make sure you can use Midjourney drawing in Discord)

  • Go to the dialog box in Discord with Midjourney Bot -
  • Open the developer tools of any browser (right click/F12) and check the network option
  • Send any drawing request
  • Search for interaction in Developer Tools and check the request header and load example: ! weixin ! weixin-2
  1. Fill the information in the request header into sender_params.json. It is worth noting that if you need multi-threaded drawing, please fill in the channelid array with the channelid of different channels (the maximum number of concurrency is 3 for Standard plan, 12 for PRO plan)

4、 Start Web-API

pip -r requirements.txt
python app.py
  1. (Optional) Go to app.py to configure cross-domain
nano app.py

(Updated) Introduction to external API usage:

Request method

  • post request: http://localhost:5000/api/send_and_receive"
  • Optional parameter: cdn=true (default false, after enabling the server will cache the image before sending, continental access is more friendly) Example:
import requests
import json

payload = {
    "prompt": "your_prompt_here"
}

url = "http://localhost:5000/api/send_and_receive";

response = requests.post(url, data=json.dumps(payload), headers={'Content-Type': 'application/json'})

print(response.json())
  • get request: http://localhost:5000/upscale"
  • Mandatory parameter: file_name(string), the name of the file that needs to be executed upscale (e.g. rockgifinrock1971_link_and_zelda_33e8886f-adae-4579-9882-bae644005f5b.png)
  • Mandatory parameter: number (number), the serial number of the image that needs to be executed upscale (example 1/2/3/4).
  • Optional parameters: cdn=true (default false, after enabling the server will cache pictures before sending, continental access more friendly) Example:
import requests

base_url = 'http://localhost:5000' # Replace with the URL your Flask application is actually running on
file_name = 'rockgifinrock1971_link_and_zelda_33e8886f-adae-4579-9882-bae644005f5b.png' # Replace with your actual file name
number = 3 # Replace with the number you want to use

response = requests.get(f'{base_url}/upscale', params={'file_name': file_name, 'number': number})

if response.status_code == 200.
    print('Success!')
    print(response.json())
else.
    print(f'Error: {response.status_code}')
    print(response.text)

Q&A

Q: How often is the information in sender_params.json updated? A: It has been two weeks since the project was run, and it is still not expired.

Future plan

  • Model switching
  • Multi-account concurrency
  • easier cookie retrieval

Contact:

For suggestions and cooperation: [email protected] Ask the author to eat Crazy Thursday to speed up the project: https://afdian.net/a/hiripple/plan

License

MIT

Additions

Sender.py and Receiver.py are based on https://github.com/George-iam/Midjourney_api二次开发

midjourney-web-api's People

Contributors

celestialripple avatar george-iam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.