howlongtobeat

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

README

howlongtobeat

Unofficial Go implementation of HowLongToBeat website API

Installation

$ go get github.com/RedSkiesReaperr/howlongtobeat

Example

hltb, err := howlongtobeat.New()
if err != nil {
    // error management
}

request, err := howlongtobeat.NewSearchRequest("elden ring")
if err != nil {
    // error management
}

result, err := hltb.Search(request)
if err != nil {
    // error management
}

for _, game := range result.Data {
    fmt.Println(game.Name)
}

Customize your request

After creating a SearchRequest you can send it as is or customize it, to do so you have several options:

Customize search terms
request.SetSearchTerms("new terms")
Customize target platform

You can find a list of available platforms here

request.SetPlatform(howlongtobeat.PlatformPC)
Customize pagination
// Retrieve page number 2 with a page size of 25
request.SetPagination(2, 25)
Customize game modifiers

You can find a list of available modifiers here

request.SetModifier(howlongtobeat.ModifierOnlyDlc)
Customize sorting

You can find a list of available sort kinds here

request.SetSorting(howlongtobeat.SortByReleaseDate)
Customize gameplay

You can find a list of available gameplay parts here

request.SetGameplay(howlongtobeat.PerspectiveThirdPerson, howlongtobeat.FlowPointAndClick, howlongtobeat.GenreHorror, howlongtobeat.DifficultyAll)

Dependencies

Thanks to all the authors who created and maintains the following packages:

Contributing

If you wish to contribute to this project, please follow these steps:

  1. Fork this repository.
  2. Create a branch for your feature: git checkout -b feature/feature-name
  3. Commit your changes: git commit -m 'Added a new feature'
  4. Push your branch: git push origin feature/feature-name
  5. Open a Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for details. Feel free to open issues or submit feature requests if you have ideas to enhance this project.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New() (*Client, error)

func (*Client) Search

func (c *Client) Search(request SearchRequest) (SearchResult, error)

type Difficulty added in v1.1.0

type Difficulty string
const (
	DifficultyAll Difficulty = ""
)

type Flow added in v1.0.0

type Flow string
const (
	FlowAll                  Flow = ""
	FlowIncremental          Flow = "Incremental"
	FlowMassivelyMultiplayer Flow = "Massively Multiplayer"
	FlowMultidirectional     Flow = "Multidirectional"
	FlowOnRails              Flow = "On-Rails"
	FlowPointAndClick        Flow = "Point-and-Click"
	FlowRealTime             Flow = "Real-Time"
	FlowScrolling            Flow = "Scrolling"
	FlowTurnBased            Flow = "Turn-Based"
)

type Game

type Game struct {
	Id                   int    `json:"game_id"`
	Name                 string `json:"game_name"`
	NameDate             int    `json:"game_name_date"`
	Alias                string `json:"game_alias"`
	Type                 string `json:"game_type"`
	Image                string `json:"game_image"`
	CompletionLvlCombine int    `json:"comp_lvl_combine"`
	CompletionLvlSp      int    `json:"comp_lvl_sp"`
	CompletionLvlCo      int    `json:"comp_lvl_co"`
	CompletionLvlMp      int    `json:"comp_lvl_mp"`
	CompletionLvlSpd     int    `json:"comp_lvl_spd"`
	CompletionMain       int    `json:"comp_main"`
	CompletionPlus       int    `json:"comp_plus"`
	CompletionFull       int    `json:"comp_100"`
	CompletionAll        int    `json:"comp_all"`
	CompletionMainCount  int    `json:"comp_main_count"`
	CompletionPlusCount  int    `json:"comp_plus_count"`
	CompletionFullCount  int    `json:"comp_100_count"`
	CompletionAllCount   int    `json:"comp_all_count"`
	InvestedCo           int    `json:"invested_co"`
	InvestedMp           int    `json:"invested_mp"`
	InvestedCoCount      int    `json:"invested_co_count"`
	InvestedMpCount      int    `json:"invested_mp_count"`
	CountCompletion      int    `json:"count_comp"`
	CountSpeedrun        int    `json:"count_speedrun"`
	CountBacklog         int    `json:"count_backlog"`
	CountReview          int    `json:"count_review"`
	ReviewScore          int    `json:"review_score"`
	CountPlaying         int    `json:"count_playing"`
	CountRetired         int    `json:"count_retired"`
	ProfilePopular       int    `json:"profile_popular"`
	ReleaseWord          int    `json:"release_world"`
}

type Genre added in v1.0.0

type Genre string
const (
	GenreAll              Genre = ""
	GenreAction           Genre = "Action"
	GenreAdventure        Genre = "Adventure"
	GenreArcade           Genre = "Arcade"
	GenreBattleArena      Genre = "Battle Arena"
	GenreBeatEmUp         Genre = "Beat em Up"
	GenreBoardGame        Genre = "Board Game"
	GenreBreakout         Genre = "Breakout"
	GenreCardGame         Genre = "Card Game"
	GenreCityBuilding     Genre = "City-Building"
	GenreCompilation      Genre = "Compilation"
	GenreEducational      Genre = "Educational"
	GenreFighting         Genre = "Fighting"
	GenreFitness          Genre = "Fitness"
	GenreFlight           Genre = "Flight"
	GenreFullMotionVideo  Genre = "Full Motion Video (FMV)"
	GenreHackAndSlash     Genre = "Hack and Slash"
	GenreHiddenObject     Genre = "Hidden Object"
	GenreHorror           Genre = "Horror"
	GenreInteractiveArt   Genre = "Interactive Art"
	GenreManagement       Genre = "Management"
	GenreMusicAndRhythm   Genre = "Music/Rhythm"
	GenreOpenWorld        Genre = "Open World"
	GenreParty            Genre = "Party"
	GenrePinball          Genre = "Pinball"
	GenrePlatform         Genre = "Platform"
	GenrePuzzle           Genre = "Puzzle"
	GenreRacingAndDriving Genre = "Racing/Driving"
	GenreRoguelike        Genre = "Roguelike"
	GenreRolePlaying      Genre = "Role-Playing"
	GenreSandbox          Genre = "Sandbox"
	GenreShooter          Genre = "Shooter"
	GenreSimulation       Genre = "Simulation"
	GenreSocial           Genre = "Social"
	GenreSports           Genre = "Sports"
	GenreStealth          Genre = "Stealth"
	GenreStrategyTactical Genre = "Strategy/Tactical"
	GenreSurvival         Genre = "Survival"
	GenreTowerDefense     Genre = "Tower Defense"
	GenreTrivia           Genre = "Trivia"
	GenreVehicularCombat  Genre = "Vehicular Combat"
	GenreVisualNovel      Genre = "Visual Novel"
)

type Modifier added in v1.0.0

type Modifier string
const (
	ModifierAll         Modifier = ""
	ModifierHideDlc     Modifier = "hide_dlc"
	ModifierOnlyDlc     Modifier = "only_dlc"
	ModifierOnlyMods    Modifier = "only_mods"
	ModifierOnlyHacks   Modifier = "only_hacks"
	ModifierHiddenStats Modifier = "hidden_stats"
	ModifierUserStats   Modifier = "user_stats"
)

type Perspective added in v1.0.0

type Perspective string
const (
	PerspectiveAll            Perspective = ""
	PerspectiveFirstPerson    Perspective = "First-Person"
	PerspectiveIsometric      Perspective = "Isometric"
	PerspectiveSide           Perspective = "Side"
	PerspectiveText           Perspective = "Text"
	PerspectiveThirdPerson    Perspective = "Third-Person"
	PerspectiveTopDown        Perspective = "Top-Down"
	PerspectiveVirtualReality Perspective = "Virtual Reality"
)

type Platform

type Platform string
const (
	PlatformAll                  Platform = ""
	PlatformEmulated             Platform = "Emulated"
	PlatformNintendo3DS          Platform = "Nintendo 3DS"
	PlatformNintendoSwitch       Platform = "Nintendo Switch"
	PlatformPC                   Platform = "PC"
	PlatformPlayStation3         Platform = "PlayStation 3"
	PlatformPlayStation4         Platform = "PlayStation 4"
	PlatformPlayStation5         Platform = "PlayStation 5"
	PlatformPlayStationNow       Platform = "PlayStation Now"
	PlatformWiiU                 Platform = "Wii U"
	PlatformXbox360              Platform = "Xbox 360"
	PlatformXboxOne              Platform = "Xbox One"
	PlatformXboxSeries           Platform = "Xbox Series X/S"
	Platform3DO                  Platform = "3DO"
	PlatformAcornArchimedes      Platform = "Acorn Archimedes"
	PlatformAmazonLuna           Platform = "Amazon Luna"
	PlatformAmiga                Platform = "Amiga"
	PlatformAmigaCD32            Platform = "Amiga CD32"
	PlatformAmstradCPC           Platform = "Amstrad CPC"
	PlatformAppleII              Platform = "Apple II"
	PlatformArcade               Platform = "Arcade"
	PlatformAtari2600            Platform = "Atari 2600"
	PlatformAtari5200            Platform = "Atari 5200"
	PlatformAtari7800            Platform = "Atari 7800"
	PlatformAtari8BitFamily      Platform = "Atari 8-bit Family"
	PlatformAtariJaguar          Platform = "Atari Jaguar"
	PlatformAtariJaguarCD        Platform = "Atari Jaguar CD"
	PlatformAtariLynx            Platform = "Atari Lynx"
	PlatformAtariST              Platform = "Atari ST"
	PlatformBBCMicro             Platform = "BBC Micro"
	PlatformBrowser              Platform = "Browser"
	PlatformColecoVision         Platform = "ColecoVision"
	PlatformCommodore64          Platform = "Commodore 64"
	PlatformCommodorePET         Platform = "Commodore PET"
	PlatformCommodoreVIC20       Platform = "Commodore VIC-20"
	PlatformDreamcast            Platform = "Dreamcast"
	PlatformEvercade             Platform = "Evercade"
	PlatformFMTowns              Platform = "FM Towns"
	PlatformFM7                  Platform = "FM-7"
	PlatformGameAndWatch         Platform = "Game & Watch"
	PlatformGameBoy              Platform = "Game Boy"
	PlatformGameBoyAdvance       Platform = "Game Boy Advance"
	PlatformGameBoyColor         Platform = "Game Boy Color"
	PlatformGearVR               Platform = "Gear VR"
	PlatformGizmondo             Platform = "Gizmondo"
	PlatformGoogleStadia         Platform = "Google Stadia"
	PlatformIntellivision        Platform = "Intellivision"
	PlatformInteractiveMovie     Platform = "Interactive Movie"
	PlatformLinux                Platform = "Linux"
	PlatformMac                  Platform = "Mac"
	PlatformMetaQuest            Platform = "Meta Quest"
	PlatformMobile               Platform = "Mobile"
	PlatformMSX                  Platform = "MSX"
	PlatformNGage                Platform = "N-Gage"
	PlatformNECPC88              Platform = "NEC PC-88"
	PlatformNECPC98              Platform = "NEC PC-98"
	PlatformNECPCFX              Platform = "NEC PC-FX"
	PlatformNeoGeo               Platform = "Neo Geo"
	PlatformNeoGeoCD             Platform = "Neo Geo CD"
	PlatformNeoGeoPocket         Platform = "Neo Geo Pocket"
	PlatformNES                  Platform = "NES"
	PlatformNintendo64           Platform = "Nintendo 64"
	PlatformNintendoDS           Platform = "Nintendo DS"
	PlatformNintendoGameCube     Platform = "Nintendo GameCube"
	PlatformOculusGo             Platform = "Oculus Go"
	PlatformOdyssey              Platform = "Odyssey"
	PlatformOdyssey2             Platform = "Odyssey 2"
	PlatformOnLive               Platform = "OnLive"
	PlatformOuya                 Platform = "Ouya"
	PlatformPhilipsCDi           Platform = "Philips CD-i"
	PlatformPlaydate             Platform = "Playdate"
	PlatformPlayStation          Platform = "PlayStation"
	PlatformPlayStation2         Platform = "PlayStation 2"
	PlatformPlayStationMobile    Platform = "PlayStation Mobile"
	PlatformPlayStationPortable  Platform = "PlayStation Portable"
	PlatformPlayStationVita      Platform = "PlayStation Vita"
	PlatformPlugAndPlay          Platform = "Plug & Play"
	PlatformSega32X              Platform = "Sega 32X"
	PlatformSegaCD               Platform = "Sega CD"
	PlatformSegaGameGear         Platform = "Sega Game Gear"
	PlatformSegaMasterSystem     Platform = "Sega Master System"
	PlatformSegaMegaDriveGenesis Platform = "Sega Mega Drive/Genesis"
	PlatformSegaPico             Platform = "Sega Pico"
	PlatformSegaSaturn           Platform = "Sega Saturn"
	PlatformSG1000               Platform = "SG-1000"
	PlatformSharpX1              Platform = "Sharp X1"
	PlatformSharpX68000          Platform = "Sharp X68000"
	PlatformSuperNintendo        Platform = "Super Nintendo"
	PlatformTigerHandheld        Platform = "Tiger Handheld"
	PlatformTurboGrafx16         Platform = "TurboGrafx-16"
	PlatformTurboGrafxCD         Platform = "TurboGrafx-CD"
	PlatformVectrex              Platform = "Vectrex"
	PlatformVirtualBoy           Platform = "Virtual Boy"
	PlatformWii                  Platform = "Wii"
	PlatformWindowsPhone         Platform = "Windows Phone"
	PlatformWonderSwan           Platform = "WonderSwan"
	PlatformXbox                 Platform = "Xbox"
	PlatformZeebo                Platform = "Zeebo"
	PlatformZXSpectrum           Platform = "ZX Spectrum"
	PlatformZX81                 Platform = "ZX81"
)

type SearchRequest

type SearchRequest struct {
	SearchType    SearchType    `json:"searchType,required"`
	SearchTerms   []string      `json:"searchTerms,required"`
	SearchPage    int           `json:"searchPage,required"`
	PageSize      int           `json:"size,required"`
	SearchOptions searchOptions `json:"searchOptions,required"`
}

func NewSearchRequest

func NewSearchRequest(searchTerms string) (SearchRequest, error)

func (*SearchRequest) SetGameplay added in v1.0.0

func (s *SearchRequest) SetGameplay(pers Perspective, flow Flow, genre Genre, difficulty Difficulty)

func (*SearchRequest) SetModifier added in v1.0.0

func (s *SearchRequest) SetModifier(modifier Modifier)

func (*SearchRequest) SetPagination

func (s *SearchRequest) SetPagination(pageIndex, pageSize int)

func (*SearchRequest) SetPlatform

func (s *SearchRequest) SetPlatform(newP Platform)

func (*SearchRequest) SetSearchTerms

func (s *SearchRequest) SetSearchTerms(terms string)

func (*SearchRequest) SetSorting added in v1.0.0

func (s *SearchRequest) SetSorting(sort SortBy)

type SearchResult

type SearchResult struct {
	Color       string `json:"color"`
	Title       string `json:"title"`
	Category    string `json:"category"`
	Count       int    `json:"count"`
	PageCurrent int    `json:"pageCurrent"`
	PageTotal   int    `json:"pageTotal"`
	PageSize    int    `json:"pageSize"`
	Data        []Game `json:"data"`
}

type SearchType

type SearchType string
const (
	SearchTypeGames SearchType = "games"
)

type SortBy added in v1.0.0

type SortBy string
const (
	SortByName            SortBy = "name"
	SortByMainStory       SortBy = "main"
	SortByMainPlusExtra   SortBy = "mainp"
	SortByCompletionist   SortBy = "comp"
	SortByAverageTime     SortBy = "averagea"
	SortByTopRated        SortBy = "rating"
	SortByMostPopular     SortBy = "popular"
	SortByMostBacklogs    SortBy = "backlog"
	SortByMostSubmissions SortBy = "usersp"
	SortByMostPlayed      SortBy = "playing"
	SortByMostSpeedruns   SortBy = "speedruns"
	SortByMostReviews     SortBy = "reviews"
	SortByReleaseDate     SortBy = "release"
)

Jump to

Keyboard shortcuts

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