Documentation ¶
Overview ¶
Package midjourney provides a basic read-only API client for MidJourney. As there is no official API, it uses the same API as the MidJourney website uses, meaning that it is subject to change at any time, breaking this package.
Index ¶
- Constants
- Variables
- type APIClient
- func (ac *APIClient) Delete(ctx context.Context, path string, params url.Values, body any, x any) error
- func (ac *APIClient) Do(req *http.Request) (*http.Response, error)
- func (ac *APIClient) Get(ctx context.Context, path string, params url.Values, x any) error
- func (ac *APIClient) Patch(ctx context.Context, path string, params url.Values, body any, x any) error
- func (ac *APIClient) Post(ctx context.Context, path string, params url.Values, body any, x any) error
- func (ac *APIClient) Put(ctx context.Context, path string, params url.Values, body any, x any) error
- func (ac *APIClient) Request(ctx context.Context, method string, path string, params url.Values, body any, ...) error
- func (ac *APIClient) Set(options ...Option) error
- type AlgorithmVersion
- type Client
- func (c *Client) ArchiveDay(ctx context.Context, date time.Time) (jobIDs []string, err error)
- func (c *Client) Bookmarks(ctx context.Context, userID string) (*RecentJobs, error)
- func (c *Client) CollectionFeed(ctx context.Context, collectionID string) (*RecentJobs, error)
- func (c *Client) CollectionJobsAdd(ctx context.Context, collectionID string, jobIDs []string) (*CollectionJobsResult, error)
- func (c *Client) CollectionJobsRemove(ctx context.Context, collectionID string, jobIDs []string) (*CollectionJobsResult, error)
- func (c *Client) Collections(ctx context.Context, query *CollectionsQuery) ([]*Collection, error)
- func (c *Client) CommunityFeed(ctx context.Context) (*RecentJobs, error)
- func (c *Client) DeleteCollection(ctx context.Context, collectionID string) (*Collection, error)
- func (c *Client) GetCollection(ctx context.Context, collectionID string) (*Collection, error)
- func (c *Client) Home(ctx context.Context, userID string) (*RecentJobs, error)
- func (c *Client) PersonalFeed(ctx context.Context) (*RecentJobs, error)
- func (c *Client) PutCollection(ctx context.Context, collection *Collection) (*Collection, error)
- func (c *Client) PutCollectionData(ctx context.Context, collectionID string, data *CollectionData) (*Collection, error)
- func (c *Client) PutCollectionFilters(ctx context.Context, collectionID string, filters *CollectionFilters) (*Collection, error)
- func (c *Client) RecentJobs(ctx context.Context, q *RecentJobsQuery) (*RecentJobs, error)
- func (ac *Client) Set(options ...Option) error
- func (c *Client) Words(ctx context.Context, q *WordsQuery) ([]*Word, error)
- type Collection
- type CollectionData
- type CollectionFilters
- type CollectionJobsResult
- type CollectionsQuery
- type Event
- type HTTPClient
- type Job
- type JobStatus
- type JobType
- type Option
- type Order
- type ParsedJobParams
- type RankedScore
- type RankedScores
- type RecentJobs
- type RecentJobsQuery
- type ResponseError
- type ThumbnailSize
- type Time
- type Word
- type WordsQuery
Constants ¶
View Source
const FromDateFormat = "2006-01-02 15:04:05.999999"
View Source
const TimeFormat = "2006-01-02 15:04:05.999999"
Variables ¶
View Source
var ( Err = errors.New("midjourney") ErrNoAuthToken = fmt.Errorf("%w: no auth token", Err) ErrInvalidAuthToken = fmt.Errorf("%w: invalid auth token", Err) ErrInvalidAPIURL = fmt.Errorf("%w: invalid API URL", Err) ErrInvalidHTTPClient = fmt.Errorf("%w: invalid HTTP client", Err) ErrNotFound = fmt.Errorf("%w: not found", Err) ErrResponse = fmt.Errorf("%w: response", Err) ErrResponseStatus = fmt.Errorf("%w: response status", ErrResponse) DefaultAPIURL = url.URL{ Scheme: "https", Host: "www.midjourney.com", Path: "/api/", } DefaultUserAgent = "go-midjourney/0.1.0" // x-release-please-version )
View Source
var ( ErrCollectionIDRequired = fmt.Errorf("%w: collection id required", Err) ErrCollectionNotFound = fmt.Errorf("%w: collection", ErrNotFound) )
View Source
var ErrJobIDsRequired = fmt.Errorf("%w: job IDs required", Err)
View Source
var ErrUserIDRequired = fmt.Errorf("%w: user id required", Err)
Functions ¶
This section is empty.
Types ¶
type APIClient ¶ added in v0.1.0
type APIClient struct { HTTPClient HTTPClient APIURL *url.URL AuthToken string UserAgent string Logger zerolog.Logger }
type AlgorithmVersion ¶
type AlgorithmVersion string
func (*AlgorithmVersion) MarshalJSON ¶
func (av *AlgorithmVersion) MarshalJSON() ([]byte, error)
func (*AlgorithmVersion) UnmarshalJSON ¶
func (av *AlgorithmVersion) UnmarshalJSON(b []byte) error
type Client ¶
type Client struct {
API *APIClient
}
func (*Client) ArchiveDay ¶
func (*Client) CollectionFeed ¶
func (*Client) CollectionJobsAdd ¶
func (*Client) CollectionJobsRemove ¶
func (*Client) Collections ¶
func (c *Client) Collections( ctx context.Context, query *CollectionsQuery, ) ([]*Collection, error)
func (*Client) CommunityFeed ¶
func (c *Client) CommunityFeed(ctx context.Context) (*RecentJobs, error)
func (*Client) DeleteCollection ¶
func (*Client) GetCollection ¶
func (*Client) PersonalFeed ¶
func (c *Client) PersonalFeed(ctx context.Context) (*RecentJobs, error)
func (*Client) PutCollection ¶
func (c *Client) PutCollection( ctx context.Context, collection *Collection, ) (*Collection, error)
func (*Client) PutCollectionData ¶
func (c *Client) PutCollectionData( ctx context.Context, collectionID string, data *CollectionData, ) (*Collection, error)
func (*Client) PutCollectionFilters ¶
func (c *Client) PutCollectionFilters( ctx context.Context, collectionID string, filters *CollectionFilters, ) (*Collection, error)
func (*Client) RecentJobs ¶
func (c *Client) RecentJobs( ctx context.Context, q *RecentJobsQuery, ) (*RecentJobs, error)
type Collection ¶
type Collection struct { CoverJobID string `json:"cover_job_id,omitempty"` Created string `json:"created,omitempty"` CreatorAvatarJobID string `json:"creator_avatar_job_id,omitempty"` CreatorCoverJobID string `json:"creator_cover_job_id,omitempty"` CreatorID string `json:"creator_id,omitempty"` CreatorUsername string `json:"creator_username,omitempty"` Data *CollectionData `json:"data,omitempty"` Description string `json:"description,omitempty"` Hidden bool `json:"hidden,omitempty"` ID string `json:"id,omitempty"` NumJobs int `json:"num_jobs,omitempty"` Public bool `json:"public,omitempty"` PublicEditable bool `json:"public_editable,omitempty"` SearchTerms []string `json:"search_terms,omitempty"` Title string `json:"title,omitempty"` Workspaces []string `json:"workspaces,omitempty"` }
type CollectionData ¶
type CollectionData struct {
Filters *CollectionFilters `json:"filters,omitempty"`
}
type CollectionFilters ¶
type CollectionJobsResult ¶
type CollectionsQuery ¶
type CollectionsQuery struct { UserID string `url:"user_id,omitempty"` CollectionID string `url:"collection_id,omitempty"` }
func (*CollectionsQuery) URLValues ¶
func (cq *CollectionsQuery) URLValues() url.Values
type Job ¶
type Job struct { JobType string `json:"_job_type,omitempty"` Service string `json:"_service,omitempty"` ParsedParams *ParsedJobParams `json:"_parsed_params,omitempty"` CurrentStatus JobStatus `json:"current_status,omitempty"` EnqueueTime Time `json:"enqueue_time,omitempty"` Event *Event `json:"event,omitempty"` Flagged bool `json:"flagged,omitempty"` FollowedByUser bool `json:"followed_by_user,omitempty"` GridID string `json:"grid_id,omitempty"` GridNum string `json:"grid_num,omitempty"` GuildID string `json:"guild_id,omitempty"` Hidden bool `json:"hidden,omitempty"` ID string `json:"id,omitempty"` ImagePaths []string `json:"image_paths,omitempty"` IsPublished bool `json:"is_published,omitempty"` LikedByUser bool `json:"liked_by_user,omitempty"` LowPriority bool `json:"low_priority,omitempty"` Metered bool `json:"metered,omitempty"` ModHidden bool `json:"mod_hidden,omitempty"` Platform string `json:"platform,omitempty"` PlatformChannel string `json:"platform_channel,omitempty"` PlatformChannelID string `json:"platform_channel_id,omitempty"` PlatformMessageID string `json:"platform_message_id,omitempty"` PlatformThreadID string `json:"platform_thread_id,omitempty"` Prompt string `json:"prompt,omitempty"` RankedByUser bool `json:"ranked_by_user,omitempty"` RankingByUser int `json:"ranking_by_user,omitempty"` Type JobType `json:"type,omitempty"` UserID string `json:"user_id,omitempty"` Username string `json:"username,omitempty"` FullCommand string `json:"full_command,omitempty"` ReferenceJobID string `json:"reference_job_id,omitempty"` ReferenceImageNum string `json:"reference_image_num,omitempty"` }
func (*Job) DiscordURL ¶
func (*Job) ImageFilename ¶
func (*Job) MainImageURL ¶
func (*Job) ThumbnailURL ¶ added in v0.1.0
func (j *Job) ThumbnailURL(size ThumbnailSize) string
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithAPIURL ¶
func WithAuthToken ¶
WithAuthToken returns a new Option type which sets the auth token that the client will use. The authToken value can be fetched from the "__Secure-next-auth.session-token" cookie on the midjourney.com website.
func WithHTTPClient ¶
func WithHTTPClient(httpClient HTTPClient) Option
func WithLogger ¶
func WithUserAgent ¶
type ParsedJobParams ¶
type ParsedJobParams struct { Anime bool `json:"anime,omitempty"` Aspect string `json:"aspect,omitempty"` Creative bool `json:"creative,omitempty"` Fast bool `json:"fast,omitempty"` HD bool `json:"hd,omitempty"` No []string `json:"no,omitempty"` Style string `json:"style,omitempty"` Stylize int `json:"stylize,omitempty"` Test bool `json:"test,omitempty"` Testp bool `json:"testp,omitempty"` Tile bool `json:"tile,omitempty"` Upanime bool `json:"upanime,omitempty"` Upbeta bool `json:"upbeta,omitempty"` Uplight bool `json:"uplight,omitempty"` Version AlgorithmVersion `json:"version,omitempty"` Vibe bool `json:"vibe,omitempty"` Video bool `json:"video,omitempty"` }
type RankedScore ¶
type RankedScore int
const ( Unranked RankedScore = 0 Mehd RankedScore = 2 Liked RankedScore = 4 Loved RankedScore = 5 )
func (RankedScore) String ¶
func (rs RankedScore) String() string
func (RankedScore) URIParam ¶
func (rs RankedScore) URIParam() string
type RankedScores ¶
type RankedScores []RankedScore
func (RankedScores) MarshalJSON ¶
func (rs RankedScores) MarshalJSON() ([]byte, error)
func (RankedScores) URIParam ¶
func (rs RankedScores) URIParam() string
URIParam returns a string representation of the RankedScores suitable for URI parameters.
func (*RankedScores) UnmarshalJSON ¶
func (rs *RankedScores) UnmarshalJSON(data []byte) error
type RecentJobs ¶
type RecentJobs struct { Query RecentJobsQuery Jobs []*Job Page int }
type RecentJobsQuery ¶
type RecentJobsQuery struct { Amount int JobType JobType OrderBy Order UserIDRankedScore RankedScores JobStatus JobStatus UserID string UserIDLiked string CollectionID string FromDate time.Time Page int Prompt string Personal bool Dedupe bool RefreshAPI int }
func (*RecentJobsQuery) NextPage ¶
func (rjq *RecentJobsQuery) NextPage() *RecentJobsQuery
func (*RecentJobsQuery) URLValues ¶
func (rjq *RecentJobsQuery) URLValues() url.Values
type ResponseError ¶
type ResponseError struct { Message string `json:"error,omitempty"` // contains filtered or unexported fields }
func (*ResponseError) Error ¶
func (re *ResponseError) Error() string
func (*ResponseError) Unwrap ¶
func (re *ResponseError) Unwrap() error
type ThumbnailSize ¶ added in v0.1.0
type ThumbnailSize int
const ( ThumbnailSizeSmall ThumbnailSize = 128 ThumbnailSizeMedium ThumbnailSize = 384 ThumbnailSizeLarge ThumbnailSize = 640 )
Click to show internal directories.
Click to hide internal directories.