itchio

package module
v0.0.0-...-be840e4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2018 License: MIT Imports: 14 Imported by: 124

README

go-itchio

build status codecov Go Report Card GoDoc MIT licensed

go-itchio is a set of Go bindings to interact with the itch.io API

License

Licensed under MIT License, see LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBuildFileNotFound is returned when someone is asking for a non-existent file
	ErrBuildFileNotFound = errors.New("build file not found in storage")
)

Functions

func GameTraitHookFunc

func GameTraitHookFunc(
	f reflect.Type,
	t reflect.Type,
	data interface{}) (interface{}, error)

func IsAPIError

func IsAPIError(err error) bool

IsApiError returns true if an error is an itch.io API error, even if it's wrapped with github.com/pkg/errors

func ParseAPIResponse

func ParseAPIResponse(dst interface{}, res *http.Response) error

ParseAPIResponse unmarshals an HTTP response into one of out response data structures

func UploadTraitHookFunc

func UploadTraitHookFunc(
	f reflect.Type,
	t reflect.Type,
	data interface{}) (interface{}, error)

Types

type APIError

type APIError struct {
	Messages []string
}

func (*APIError) Error

func (ae *APIError) Error() string

type APIKey

type APIKey struct {
	// Site-wide unique identifier generated by itch.io
	ID int64 `json:"id"`

	// ID of the user to which the key belongs
	UserID int64 `json:"userId"`

	// Actual API key value
	Key string `json:"key"`

	CreatedAt     *time.Time `json:"createdAt"`
	UpdatedAt     *time.Time `json:"updatedAt"`
	SourceVersion string     `json:"sourceVersion"`
}

An API key grants access to the itch.io API within a certain scope.

type Build

type Build struct {
	// Site-wide unique identifier generated by itch.io
	ID int64 `json:"id"`
	// Identifier of the build before this one on the same channel,
	// or 0 if this is the initial build.
	ParentBuildID int64 `json:"parentBuildId"`
	// State of the build: started, processing, etc.
	State BuildState `json:"state"`

	// Automatically-incremented version number, starting with 1
	Version int64 `json:"version"`
	// Value specified by developer with `--userversion` when pushing a build
	// Might not be unique across builds of a given channel.
	UserVersion string `json:"userVersion"`

	// Files associated with this build - often at least an archive,
	// a signature, and a patch. Some might be missing while the build
	// is still processing or if processing has failed.
	Files []*BuildFile `json:"files"`

	// User who pushed the build
	User *User `json:"user"`
	// Timestamp the build was created at
	CreatedAt *time.Time `json:"createdAt"`
	// Timestamp the build was last updated at
	UpdatedAt *time.Time `json:"updatedAt"`
}

Build contains information about a specific build

type BuildEvent

type BuildEvent struct {
	Type    BuildEventType `json:"type"`
	Message string         `json:"message"`
	Data    BuildEventData `json:"data"`
}

A BuildEvent describes something that happened while we were processing a build.

type BuildEventData

type BuildEventData map[string]interface{}

BuildEventData is a JSON object associated with a build event

type BuildEventType

type BuildEventType string

BuildEventType specifies what kind of event a build event is - could be a log message, etc.

const (
	// BuildEventLog is for build events of type log message
	BuildEventLog BuildEventType = "log"
)

type BuildFile

type BuildFile struct {
	// Site-wide unique identifier generated by itch.io
	ID int64 `json:"id"`
	// Size of this build file
	Size int64 `json:"size"`
	// State of this file: created, uploading, uploaded, etc.
	State BuildFileState `json:"state"`
	// Type of this build file: archive, signature, patch, etc.
	Type BuildFileType `json:"type"`
	// Subtype of this build file, usually indicates compression
	SubType BuildFileSubType `json:"subType"`

	// Date this build file was created at
	CreatedAt *time.Time `json:"createdAt"`
	// Date this build file was last updated at
	UpdatedAt *time.Time `json:"updatedAt"`
}

BuildFile contains information about a build's "file", which could be its archive, its signature, its patch, etc.

func FindBuildFile

func FindBuildFile(fileType BuildFileType, files []*BuildFile) *BuildFile

FindBuildFile looks for an uploaded file of the right type in a list of file. Returns nil if it can't find one.

type BuildFileState

type BuildFileState string

BuildFileState describes the state of a specific file for a build

const (
	// BuildFileStateCreated means the file entry exists on itch.io
	BuildFileStateCreated BuildFileState = "created"
	// BuildFileStateUploading means the file is currently being uploaded to storage
	BuildFileStateUploading BuildFileState = "uploading"
	// BuildFileStateUploaded means the file is ready
	BuildFileStateUploaded BuildFileState = "uploaded"
	// BuildFileStateFailed means the file failed uploading
	BuildFileStateFailed BuildFileState = "failed"
)

type BuildFileSubType

type BuildFileSubType string

BuildFileSubType describes the subtype of a build file: mostly its compression level. For example, rediff'd patches are "optimized", whereas initial patches are "default"

const (
	// BuildFileSubTypeDefault describes default compression (rsync patches)
	BuildFileSubTypeDefault BuildFileSubType = "default"
	// BuildFileSubTypeGzip is reserved
	BuildFileSubTypeGzip BuildFileSubType = "gzip"
	// BuildFileSubTypeOptimized describes optimized compression (rediff'd / bsdiff patches)
	BuildFileSubTypeOptimized BuildFileSubType = "optimized"
)

type BuildFileType

type BuildFileType string

BuildFileType describes the type of a build file: patch, archive, signature, etc.

const (
	// BuildFileTypePatch describes wharf patch files (.pwr)
	BuildFileTypePatch BuildFileType = "patch"
	// BuildFileTypeArchive describes canonical archive form (.zip)
	BuildFileTypeArchive BuildFileType = "archive"
	// BuildFileTypeSignature describes wharf signature files (.pws)
	BuildFileTypeSignature BuildFileType = "signature"
	// BuildFileTypeManifest is reserved
	BuildFileTypeManifest BuildFileType = "manifest"
	// BuildFileTypeUnpacked describes the single file that is in the build (if it was just a single file)
	BuildFileTypeUnpacked BuildFileType = "unpacked"
)

type BuildState

type BuildState string

BuildState describes the state of a build, relative to its initial upload, and its processing.

const (
	// BuildStateStarted is the state of a build from its creation until the initial upload is complete
	BuildStateStarted BuildState = "started"
	// BuildStateProcessing is the state of a build from the initial upload's completion to its fully-processed state.
	// This state does not mean the build is actually being processed right now, it's just queued for processing.
	BuildStateProcessing BuildState = "processing"
	// BuildStateCompleted means the build was successfully processed. Its patch hasn't necessarily been
	// rediff'd yet, but we have the holy (patch,signature,archive) trinity.
	BuildStateCompleted BuildState = "completed"
	// BuildStateFailed means something went wrong with the build. A failing build will not update the channel
	// head and can be requeued by the itch.io team, although if a new build is pushed before they do,
	// that new build will "win".
	BuildStateFailed BuildState = "failed"
)

type Channel

type Channel struct {
	// Name of the channel, usually something like `windows-64-beta` or `osx-universal`
	Name string `json:"name"`
	Tags string `json:"tags"`

	Upload  *Upload `json:"upload"`
	Head    *Build  `json:"head"`
	Pending *Build  `json:"pending"`
}

Channel contains information about a channel and its current status

type Client

type Client struct {
	Key           string
	HTTPClient    *http.Client
	BaseURL       string
	RetryPatterns []time.Duration
	UserAgent     string
}

A Client allows consuming the itch.io API

func ClientWithKey

func ClientWithKey(key string) *Client

ClientWithKey creates a new itch.io API client with a given API key

func (*Client) CreateBuild

func (c *Client) CreateBuild(p *CreateBuildParams) (*CreateBuildResponse, error)

CreateBuild creates a new build for a given user/game:channel, with an optional user version

func (*Client) CreateBuildEvent

func (c *Client) CreateBuildEvent(p *CreateBuildEventParams) (*CreateBuildEventResponse, error)

CreateBuildEvent associates a new build event to a build

func (*Client) CreateBuildFailure

func (c *Client) CreateBuildFailure(p *CreateBuildFailureParams) (*CreateBuildFailureResponse, error)

CreateBuildFailure marks a given build as failed. We get to specify an error message and if it's a fatal error (if not, the build can be retried after a bit)

func (*Client) CreateBuildFile

func (c *Client) CreateBuildFile(p *CreateBuildFileParams) (*CreateBuildFileResponse, error)

CreateBuildFile creates a new build file for a build

func (*Client) CreateRediffBuildFailure

CreateRediffBuildFailure marks a given build as having failed to rediff (optimize)

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do performs a request (any method). It takes care of JWT or API key authentication, sets the propre user agent, has built-in retry,

func (*Client) FinalizeBuildFile

func (c *Client) FinalizeBuildFile(p *FinalizeBuildFileParams) (*FinalizeBuildFileResponse, error)

FinalizeBuildFile marks the end of the upload for a build file, it validates

func (*Client) Get

func (c *Client) Get(url string) (*http.Response, error)

Get performs an HTTP GET request to the API

func (*Client) GetBuild

func (c *Client) GetBuild(p *GetBuildParams) (*GetBuildResponse, error)

func (*Client) GetBuildUpgradePath

func (c *Client) GetBuildUpgradePath(p *GetBuildUpgradePathParams) (*GetBuildUpgradePathResponse, error)

func (*Client) GetChannel

func (c *Client) GetChannel(target string, channel string) (*GetChannelResponse, error)

GetChannel returns information about a given channel for a given game

func (*Client) GetCollection

func (c *Client) GetCollection(params *GetCollectionParams) (*GetCollectionResponse, error)

func (*Client) GetCollectionGames

func (c *Client) GetCollectionGames(params *GetCollectionGamesParams) (*GetCollectionGamesResponse, error)

func (*Client) GetGame

func (c *Client) GetGame(p *GetGameParams) (*GetGameResponse, error)

func (*Client) GetProfile

func (c *Client) GetProfile() (*GetProfileResponse, error)

GetProfile returns information about the user the current credentials belong to

func (*Client) GetResponse

func (c *Client) GetResponse(url string, dst interface{}) error

func (*Client) GetUpload

func (c *Client) GetUpload(params *GetUploadParams) (*GetUploadResponse, error)

func (*Client) ListBuildEvents

func (c *Client) ListBuildEvents(buildID int64) (*ListBuildEventsResponse, error)

ListBuildEvents returns a series of events associated with a given build

func (*Client) ListBuildFiles

func (c *Client) ListBuildFiles(buildID int64) (*ListBuildFilesResponse, error)

ListBuildFiles returns a list of files associated to a build

func (*Client) ListChannels

func (c *Client) ListChannels(target string) (*ListChannelsResponse, error)

ListChannels returns a list of the channels for a game

func (*Client) ListGameUploads

func (c *Client) ListGameUploads(p *ListGameUploadsParams) (*ListGameUploadsResponse, error)

ListGameUploads lists the uploads for a game that we have access to with our API key

func (*Client) ListProfileCollections

func (c *Client) ListProfileCollections() (*ListProfileCollectionsResponse, error)

ListProfileCollections lists the collections associated to a profile

func (*Client) ListProfileGames

func (c *Client) ListProfileGames() (*ListProfileGamesResponse, error)

ListProfileGames lists the games one develops (ie. can edit)

func (*Client) ListProfileOwnedKeys

func (c *Client) ListProfileOwnedKeys() (*ListProfileOwnedKeysResponse, error)

ListProfileOwnedKeys lists the download keys one owns

func (*Client) ListUploadBuilds

func (c *Client) ListUploadBuilds(params *ListUploadBuildsParams) (*ListUploadBuildsResponse, error)

func (*Client) LoginWithPassword

func (c *Client) LoginWithPassword(params *LoginWithPasswordParams) (*LoginWithPasswordResponse, error)

func (*Client) MakeBuildDownloadURL

func (c *Client) MakeBuildDownloadURL(p *MakeBuildDownloadParams) string

func (*Client) MakeBuildFileDownloadURL

func (c *Client) MakeBuildFileDownloadURL(p *MakeBuildFileDownloadURLParams) string

GetBuildFileDownloadURL returns a download URL for a given build file

func (*Client) MakePath

func (c *Client) MakePath(format string, a ...interface{}) string

MakePath crafts an API url from our configured base URL

func (*Client) MakeUploadDownloadURL

func (c *Client) MakeUploadDownloadURL(p *MakeUploadDownloadParams) string

func (*Client) MakeValuesPath

func (c *Client) MakeValuesPath(values url.Values, format string, a ...interface{}) string

MakePath crafts an API url from our configured base URL

func (*Client) NewDownloadSession

func (c *Client) NewDownloadSession(p *NewDownloadSessionParams) (*NewDownloadSessionResponse, error)

func (*Client) PostForm

func (c *Client) PostForm(url string, data url.Values) (*http.Response, error)

PostForm performs an HTTP POST request to the API, with url-encoded parameters

func (*Client) PostFormResponse

func (c *Client) PostFormResponse(url string, data url.Values, dst interface{}) error

func (*Client) SearchGames

func (c *Client) SearchGames(params *SearchGamesParams) (*SearchGamesResponse, error)

func (*Client) SearchUsers

func (c *Client) SearchUsers(params *SearchUsersParams) (*SearchUsersResponse, error)

func (*Client) SetServer

func (c *Client) SetServer(itchioServer string) *Client

SetServer allows changing the server to which we're making API requests (which defaults to the reference itch.io server)

func (*Client) Subkey

func (c *Client) Subkey(params *SubkeyParams) (*SubkeyResponse, error)

func (*Client) TOTPVerify

func (c *Client) TOTPVerify(params *TOTPVerifyParams) (*TOTPVerifyResponse, error)

func (*Client) WharfStatus

func (c *Client) WharfStatus() (*WharfStatusResponse, error)

WharfStatus requests the status of the wharf infrastructure

type Collection

type Collection struct {
	// Site-wide unique identifier generated by itch.io
	ID int64 `json:"id"`

	// Human-friendly title for collection, for example `Couch coop games`
	Title string `json:"title"`

	// Date this collection was created at
	CreatedAt *time.Time `json:"createdAt"`
	// Date this collection was last updated at (item added, title set, etc.)
	UpdatedAt *time.Time `json:"updatedAt"`

	// Number of games in the collection. This might not be accurate
	// as some games might not be accessible to whoever is asking (project
	// page deleted, visibility level changed, etc.)
	GamesCount int64 `json:"gamesCount"`

	// Games in this collection, with additional info
	CollectionGames []*CollectionGame `json:"collectionGames,omitempty"`

	UserID int64 `json:"userId"`
	User   *User `json:"user,omitempty"`
}

A Collection is a set of games, curated by humans.

type CollectionGame

type CollectionGame struct {
	CollectionID int64       `json:"collectionId" gorm:"primary_key;auto_increment:false"`
	Collection   *Collection `json:"collection,omitempty"`

	GameID int64 `json:"gameId" gorm:"primary_key;auto_increment:false"`
	Game   *Game `json:"game,omitempty"`

	Position int64 `json:"position"`

	CreatedAt *time.Time `json:"createdAt"`
	UpdatedAt *time.Time `json:"updatedAt"`

	Blurb  string `json:"blurb"`
	UserID int64  `json:"userId"`
}
type Cookie map[string]string

type CreateBuildEventParams

type CreateBuildEventParams struct {
	BuildID int64
	Type    BuildEventType
	Message string
	Data    BuildEventData
}

type CreateBuildEventResponse

type CreateBuildEventResponse struct{}

CreateBuildEventResponse is what the API responds with when you create a new build event

type CreateBuildFailureParams

type CreateBuildFailureParams struct {
	BuildID int64
	Message string
	Fatal   bool
}

type CreateBuildFailureResponse

type CreateBuildFailureResponse struct{}

CreateBuildFailureResponse is what the API responds with when we mark a build as failed

type CreateBuildFileParams

type CreateBuildFileParams struct {
	BuildID        int64
	Type           BuildFileType
	SubType        BuildFileSubType
	FileUploadType FileUploadType
	Filename       string
}

type CreateBuildFileResponse

type CreateBuildFileResponse struct {
	File *FileUploadSpec `json:"file"`
}

CreateBuildFileResponse is what the API responds when we create a new build file

type CreateBuildParams

type CreateBuildParams struct {
	Target      string
	Channel     string
	UserVersion string
}

type CreateBuildResponse

type CreateBuildResponse struct {
	Build struct {
		ID          int64 `json:"id"`
		UploadID    int64 `json:"uploadId"`
		ParentBuild struct {
			ID int64 `json:"id"`
		} `json:"parentBuild"`
	}
}

CreateBuildResponse is what the API replies with when we create a new build

type CreateRediffBuildFailureParams

type CreateRediffBuildFailureParams struct {
	BuildID int64
	Message string
}

type CreateRediffBuildFailureResponse

type CreateRediffBuildFailureResponse struct{}

type DownloadBuildFileResponse

type DownloadBuildFileResponse struct {
	URL string `json:"url"`
}

DownloadBuildFileResponse is what the API responds with when we ask to download an upload

type DownloadKey

type DownloadKey struct {
	// Site-wide unique identifier generated by itch.io
	ID int64 `json:"id"`

	// Identifier of the game to which this download key grants access
	GameID int64 `json:"gameId"`

	// Game to which this download key grants access
	Game *Game `json:"game,omitempty"`

	// Date this key was created at (often coincides with purchase time)
	CreatedAt *time.Time `json:"createdAt"`
	// Date this key was last updated at
	UpdatedAt *time.Time `json:"updatedAt"`

	// Identifier of the itch.io user to which this key belongs
	OwnerID int64 `json:"ownerId"`
}

A download key is often generated when a purchase is made, it allows downloading uploads for a game that are not available for free.

type DownloadUploadBuildResponse

type DownloadUploadBuildResponse struct {
	// Patch is the download info for the wharf patch, if any
	Patch *DownloadUploadBuildResponseItem `json:"patch"`
	// Signature is the download info for the wharf signature, if any
	Signature *DownloadUploadBuildResponseItem `json:"signature"`
	// Manifest is reserved
	Manifest *DownloadUploadBuildResponseItem `json:"manifest"`
	// Archive is the download info for the .zip archive, if any
	Archive *DownloadUploadBuildResponseItem `json:"archive"`
	// Unpacked is the only file of the build, if it's a single file
	Unpacked *DownloadUploadBuildResponseItem `json:"unpacked"`
}

DownloadUploadBuildResponse is what the API responds when we want to download a build

type DownloadUploadBuildResponseItem

type DownloadUploadBuildResponseItem struct {
	URL string `json:"url"`
}

DownloadUploadBuildResponseItem contains download information for a specific build file

type FileUploadSpec

type FileUploadSpec struct {
	ID            int64             `json:"id"`
	UploadURL     string            `json:"uploadUrl"`
	UploadParams  map[string]string `json:"uploadParams"`
	UploadHeaders map[string]string `json:"uploadHeaders"`
}

FileUploadSpec contains the info needed to upload one specific build file

type FileUploadType

type FileUploadType string

FileUploadType describes which strategy is used for uploading to storage some types allow for uploading in blocks (which is resumable), some expect the whole payload in one request.

const (
	// FileUploadTypeMultipart lets you send metadata + all the content in a single request
	FileUploadTypeMultipart FileUploadType = "multipart"
	// FileUploadTypeResumable lets you send blocks of N*128KB at a time. The upload session is
	// started from the API server, so the ingest point will be anchored wherever the API server is.
	FileUploadTypeResumable FileUploadType = "resumable"
	// FileUploadTypeDeferredResumable also lets you send blocks of N*128KB at a time, but it
	// lets you start the upload session from the client, which means you might get a closer ingest point.
	FileUploadTypeDeferredResumable FileUploadType = "deferred_resumable"
)

type FinalizeBuildFileParams

type FinalizeBuildFileParams struct {
	BuildID int64
	FileID  int64
	Size    int64
}

type FinalizeBuildFileResponse

type FinalizeBuildFileResponse struct{}

FinalizeBuildFileResponse is what the API responds when we finalize a build file

type Game

type Game struct {
	// Site-wide unique identifier generated by itch.io
	ID int64 `json:"id"`
	// Canonical address of the game's page on itch.io
	URL string `json:"url"`

	// Human-friendly title (may contain any character)
	Title string `json:"title"`
	// Human-friendly short description
	ShortText string `json:"shortText"`
	// Downloadable game, html game, etc.
	Type GameType `json:"type"`
	// Classification: game, tool, comic, etc.
	Classification GameClassification `json:"classification"`

	// Configuration for embedded (HTML5) games
	// @optional
	Embed *GameEmbedData `json:"embed,omitempty"`

	// Cover url (might be a GIF)
	CoverURL string `json:"coverUrl"`
	// Non-gif cover url, only set if main cover url is a GIF
	StillCoverURL string `json:"stillCoverUrl"`

	// Date the game was created
	CreatedAt *time.Time `json:"createdAt"`
	// Date the game was published, empty if not currently published
	PublishedAt *time.Time `json:"publishedAt"`

	// Price in cents of a dollar
	MinPrice int64 `json:"minPrice"`

	// Traits describes the platforms a game is available for,
	// pricing information, etc.
	Traits GameTraits `json:"traits"`

	// The user account this game is associated to
	// @optional
	User *User `json:"user,omitempty"`

	// ID of the user account this game is associated to
	UserID int64 `json:"userId"`

	// The best current sale for this game
	// @optional
	Sale *Sale `json:"sale,omitempty"`

	ViewsCount     int64 `json:"viewsCount,omitempty" gorm:"-"`
	DownloadsCount int64 `json:"downloadsCount,omitempt" gorm:"-"`
	PurchasesCount int64 `json:"purchasesCount,omitempt" gorm:"-"`

	Published bool `json:"published,omitempty" gorm:"-"`
}

Game represents a page on itch.io, it could be a game, a tool, a comic, etc.

type GameClassification

type GameClassification string

Creator-picked classification for a page

const (
	// something you can play
	GameClassificationGame GameClassification = "game"
	// all software pretty much
	GameClassificationTool GameClassification = "tool"
	// assets: graphics, sounds, etc.
	GameClassificationAssets GameClassification = "assets"
	// game mod (no link to game, purely creator tagging)
	GameClassificationGameMod GameClassification = "game_mod"
	// printable / board / card game
	GameClassificationPhysicalGame GameClassification = "physical_game"
	// bunch of music files
	GameClassificationSoundtrack GameClassification = "soundtrack"
	// anything that creators think don't fit in any other category
	GameClassificationOther GameClassification = "other"
	// comic book (pdf, jpg, specific comic formats, etc.)
	GameClassificationComic GameClassification = "comic"
	// book (pdf, jpg, specific e-book formats, etc.)
	GameClassificationBook GameClassification = "book"
)

type GameCredentials

type GameCredentials struct {
	DownloadKeyID int64
	Password      string
	Secret        string
}

type GameEmbedData

type GameEmbedData struct {
	// Game this embed info is for
	GameID int64 `json:"gameId" gorm:"primary_key;auto_increment:false"`

	// width of the initial viewport, in pixels
	Width int64 `json:"width"`

	// height of the initial viewport, in pixels
	Height int64 `json:"height"`

	// for itch.io website, whether or not a fullscreen button should be shown
	Fullscreen bool `json:"fullscreen"`
}

Presentation information for embed games

type GameTraits

type GameTraits struct {
	PlatformWindows bool `trait:"p_windows"`
	PlatformLinux   bool `trait:"p_linux"`
	PlatformOSX     bool `trait:"p_osx"`
	PlatformAndroid bool `trait:"p_android"`
	CanBeBought     bool `trait:"can_be_bought"`
	HasDemo         bool `trait:"has_demo"`
	InPressSystem   bool `trait:"in_press_system"`
}

func (GameTraits) MarshalJSON

func (tt GameTraits) MarshalJSON() ([]byte, error)

func (*GameTraits) UnmarshalJSON

func (tt *GameTraits) UnmarshalJSON(data []byte) error

type GameType

type GameType string

Type of an itch.io game page, mostly related to how it should be presented on web (downloadable or embed)

const (
	// downloadable
	GameTypeDefault GameType = "default"
	// .swf (legacy)
	GameTypeFlash GameType = "flash"
	// .unity3d (legacy)
	GameTypeUnity GameType = "unity"
	// .jar (legacy)
	GameTypeJava GameType = "java"
	// .html (thriving)
	GameTypeHTML GameType = "html"
)

type GetBuildParams

type GetBuildParams struct {
	BuildID int64

	// Optional
	Credentials GameCredentials
}

type GetBuildResponse

type GetBuildResponse struct {
	Build *Build `json:"build"`
}

type GetBuildUpgradePathParams

type GetBuildUpgradePathParams struct {
	CurrentBuildID int64
	TargetBuildID  int64

	// Optional
	Credentials GameCredentials
}

type GetBuildUpgradePathResponse

type GetBuildUpgradePathResponse struct {
	UpgradePath *UpgradePath `json:"upgradePath"`
}

type GetChannelResponse

type GetChannelResponse struct {
	Channel *Channel `json:"channel"`
}

GetChannelResponse is what the API responds with when we ask info about a channel

type GetCollectionGamesParams

type GetCollectionGamesParams struct {
	CollectionID int64
	Page         int64
}

type GetCollectionGamesResponse

type GetCollectionGamesResponse struct {
	Page            int64             `json:"page"`
	PerPage         int64             `json:"perPage"`
	CollectionGames []*CollectionGame `json:"collection_games"`
}

type GetCollectionParams

type GetCollectionParams struct {
	CollectionID int64 `json:"collectionId"`
}

type GetCollectionResponse

type GetCollectionResponse struct {
	Collection *Collection `json:"collection"`
}

GetCollectionResponse is what the API server responds when we ask for a collection's info

type GetGameParams

type GetGameParams struct {
	GameID int64

	Credentials GameCredentials
}

type GetGameResponse

type GetGameResponse struct {
	Game *Game `json:"game"`
}

GetGameResponse is what the API server responds when we ask for a game's info

type GetProfileResponse

type GetProfileResponse struct {
	User *User `json:"user"`
}

GetProfileResponse is what the API server responds when we ask for the user's profile

type GetUploadParams

type GetUploadParams struct {
	UploadID int64

	// Optional
	Credentials GameCredentials
}

type GetUploadResponse

type GetUploadResponse struct {
	Upload *Upload `json:"upload"`
}

type ListBuildEventsResponse

type ListBuildEventsResponse struct {
	Events []*BuildEvent `json:"events"`
}

ListBuildEventsResponse is what the API responds with when we ask for the list of events for a build

type ListBuildFilesResponse

type ListBuildFilesResponse struct {
	Files []*BuildFile `json:"files"`
}

ListBuildFilesResponse is what the API responds with when we ask for the files in a specific build

type ListChannelsResponse

type ListChannelsResponse struct {
	Channels map[string]*Channel `json:"channels"`
}

ListChannelsResponse is what the API responds with when we ask for all the channels of a particular game

type ListGameUploadsParams

type ListGameUploadsParams struct {
	GameID int64

	// Optional
	Credentials GameCredentials
}

type ListGameUploadsResponse

type ListGameUploadsResponse struct {
	Uploads []*Upload `json:"uploads"`
}

ListGameUploadsResponse is what the server replies with when asked for a game's uploads

type ListProfileCollectionsResponse

type ListProfileCollectionsResponse struct {
	Collections []*Collection `json:"collections"`
}

ListProfileCollectionsResponse is the response for /profile/collections

type ListProfileGamesResponse

type ListProfileGamesResponse struct {
	Games []*Game `json:"games"`
}

ListProfileGamesResponse is what the API server answers when we ask for what games an account develops.

type ListProfileOwnedKeysResponse

type ListProfileOwnedKeysResponse struct {
	OwnedKeys []*DownloadKey `json:"ownedKeys"`
}

ListProfileOwnedKeysResponse is the response for /profile/owned-keys

type ListUploadBuildsParams

type ListUploadBuildsParams struct {
	UploadID int64

	// Optional
	Credentials GameCredentials
}

type ListUploadBuildsResponse

type ListUploadBuildsResponse struct {
	Builds []*Build `json:"builds"`
}

type LoginWithPasswordParams

type LoginWithPasswordParams struct {
	Username          string
	Password          string
	RecaptchaResponse string
}

type LoginWithPasswordResponse

type LoginWithPasswordResponse struct {
	RecaptchaNeeded bool   `json:"recaptchaNeeded"`
	RecaptchaURL    string `json:"recaptchaUrl"`
	TOTPNeeded      bool   `json:"totpNeeded"`
	Token           string `json:"token"`

	Key    *APIKey `json:"key"`
	Cookie Cookie  `json:"cookie"`
}

type MakeBuildDownloadParams

type MakeBuildDownloadParams struct {
	BuildID int64
	Type    BuildFileType

	// Optional: Defaults to BuildFileSubTypeDefault
	SubType BuildFileSubType

	// Optional
	UUID string

	// Optional
	Credentials GameCredentials
}

type MakeBuildFileDownloadURLParams

type MakeBuildFileDownloadURLParams struct {
	BuildID int64
	FileID  int64
}

type MakeUploadDownloadParams

type MakeUploadDownloadParams struct {
	UploadID int64

	// Optional
	UUID string

	// Optional
	Credentials GameCredentials
}

type NewDownloadSessionParams

type NewDownloadSessionParams struct {
	GameID int64

	Credentials GameCredentials
}

type NewDownloadSessionResponse

type NewDownloadSessionResponse struct {
	UUID string `json:"uuid"`
}

type Query

type Query struct {
	Client *Client
	Path   string
	Values url.Values
}

func NewQuery

func NewQuery(c *Client, format string, a ...interface{}) *Query

func (*Query) AddAPICredentials

func (q *Query) AddAPICredentials()

func (*Query) AddBoolIfTrue

func (q *Query) AddBoolIfTrue(key string, value bool)

func (*Query) AddGameCredentials

func (q *Query) AddGameCredentials(gc GameCredentials)

func (*Query) AddInt64

func (q *Query) AddInt64(key string, value int64)

func (*Query) AddInt64IfNonZero

func (q *Query) AddInt64IfNonZero(key string, value int64)

func (*Query) AddString

func (q *Query) AddString(key string, value string)

func (*Query) AddStringIfNonEmpty

func (q *Query) AddStringIfNonEmpty(key string, value string)

func (*Query) AddValues

func (q *Query) AddValues(values url.Values)

func (*Query) Get

func (q *Query) Get(r interface{}) error

func (*Query) Post

func (q *Query) Post(r interface{}) error

func (*Query) URL

func (q *Query) URL() string

type Sale

type Sale struct {
	// Site-wide unique identifier generated by itch.io
	ID int64 `json:"id"`

	// Game this sale is for
	GameID int64 `json:"gameId"`

	// Discount rate in percent.
	// Can be negative, see https://itch.io/updates/introducing-reverse-sales
	Rate float64 `json:"rate"`
	// Timestamp the sale started at
	StartDate string `json:"startDate"`
	// Timestamp the sale ends at
	EndDate string `json:"endDate"`
}

Describes a discount for a game.

type SearchGamesParams

type SearchGamesParams struct {
	Query string
	Page  int64
}

type SearchGamesResponse

type SearchGamesResponse struct {
	Page    int64   `json:"page"`
	PerPage int64   `json:"perPage"`
	Games   []*Game `json:"games"`
}

type SearchUsersParams

type SearchUsersParams struct {
	Query string
	Page  int64
}

type SearchUsersResponse

type SearchUsersResponse struct {
	Page    int64   `json:"page"`
	PerPage int64   `json:"perPage"`
	Users   []*User `json:"users"`
}

type Spec

type Spec struct {
	Target  string
	Channel string
}

A Spec points to a given itch.io game, optionally to a specific channel

func ParseSpec

func ParseSpec(specIn string) (*Spec, error)

ParseSpec parses something of the form `user/page:channel` and returns `user/page` and `channel` separately

func (*Spec) EnsureChannel

func (spec *Spec) EnsureChannel() error

EnsureChannel returns an error if this spec is missing a channel

func (*Spec) String

func (spec *Spec) String() string

type SubkeyParams

type SubkeyParams struct {
	GameID int64
	Scope  string
}

type SubkeyResponse

type SubkeyResponse struct {
	Key       string `json:"key"`
	ExpiresAt string `json:"expiresAt"`
}

type TOTPVerifyParams

type TOTPVerifyParams struct {
	Token string
	Code  string
}

type TOTPVerifyResponse

type TOTPVerifyResponse struct {
	Key    *APIKey `json:"key"`
	Cookie Cookie  `json:"cookie"`
}

type UpgradePath

type UpgradePath struct {
	Builds []*Build `json:"builds"`
}

type Upload

type Upload struct {
	// Site-wide unique identifier generated by itch.io
	ID int64 `json:"id"`
	// Original file name (example: `Overland_x64.zip`)
	Filename string `json:"filename"`
	// Human-friendly name set by developer (example: `Overland for Windows 64-bit`)
	DisplayName string `json:"displayName"`
	// Size of upload in bytes. For wharf-enabled uploads, it's the archive size.
	Size int64 `json:"size"`
	// Name of the wharf channel for this upload, if it's a wharf-enabled upload
	ChannelName string `json:"channelName"`
	// Latest build for this upload, if it's a wharf-enabled upload
	Build *Build `json:"build"`

	// Upload type: default, soundtrack, etc.
	Type UploadType `json:"type"`

	// Traits describes platform availability, whether it's a demo upload etc.
	Traits UploadTraits `json:"traits"`

	// Date this upload was created at
	CreatedAt *time.Time `json:"createdAt"`
	// Date this upload was last updated at (order changed, display name set, etc.)
	UpdatedAt *time.Time `json:"updatedAt"`
}

An Upload is a downloadable file. Some are wharf-enabled, which means they're actually a "channel" that may contain multiple builds, pushed with <https://github.com/itchio/butler>

type UploadDownloadResponse

type UploadDownloadResponse struct {
	URL string `json:"url"`
}

UploadDownloadResponse is what the API replies to when we ask to download an upload

type UploadTraits

type UploadTraits struct {
	PlatformWindows bool `trait:"p_windows"`
	PlatformLinux   bool `trait:"p_linux"`
	PlatformOSX     bool `trait:"p_osx"`
	PlatformAndroid bool `trait:"p_android"`
	Preorder        bool `trait:"preorder"`
	Demo            bool `trait:"demo"`
}

func (UploadTraits) MarshalJSON

func (tt UploadTraits) MarshalJSON() ([]byte, error)

func (*UploadTraits) UnmarshalJSON

func (tt *UploadTraits) UnmarshalJSON(data []byte) error

type UploadType

type UploadType string
const (
	UploadTypeDefault UploadType = "default"

	//----------------
	// embed types
	//----------------
	UploadTypeFlash UploadType = "flash"
	UploadTypeUnity UploadType = "unity"
	UploadTypeJava  UploadType = "java"
	UploadTypeHTML  UploadType = "html"

	//----------------
	// asorted types
	//----------------
	UploadTypeSoundtrack      UploadType = "soundtrack"
	UploadTypeBook            UploadType = "book"
	UploadTypeVideo           UploadType = "video"
	UploadTypeDocumentation   UploadType = "documentation"
	UploadTypeMod             UploadType = "mod"
	UploadTypeAudioAssets     UploadType = "audio_assets"
	UploadTypeGraphicalAssets UploadType = "graphical_assets"
	UploadTypeSourcecode      UploadType = "sourcecode"
	UploadTypeOther           UploadType = "other"
)

type User

type User struct {
	// Site-wide unique identifier generated by itch.io
	ID int64 `json:"id"`

	// The user's username (used for login)
	Username string `json:"username"`
	// The user's display name: human-friendly, may contain spaces, unicode etc.
	DisplayName string `json:"displayName"`

	// Has the user opted into creating games?
	Developer bool `json:"developer" gorm:"-"`
	// Is the user part of itch.io's press program?
	PressUser bool `json:"pressUser" gorm:"-"`

	// The address of the user's page on itch.io
	URL string `json:"url"`
	// User's avatar, may be a GIF
	CoverURL string `json:"coverUrl"`
	// Static version of user's avatar, only set if the main cover URL is a GIF
	StillCoverURL string `json:"stillCoverUrl"`
}

User represents an itch.io account, with basic profile info

type WharfStatusResponse

type WharfStatusResponse struct {
	Success bool `json:"success"`
}

WharfStatusResponse is what the API responds with when we ask for the status of the wharf infrastructure

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL