enkanetworkapigo

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 14 Imported by: 0

README

enka-network-api-go

API wrapper for https://enka.network/ in go

Requirements

I wrote it in go 1.21, will probably work with lower versions. idk It's all very straightforward usage, some examples can be found in the examples folder

Instalation

go get github.com/Fesaa/enka-network-api-go

Note

I stole the fields from the java version :D Feel free to message me on discord if needed ameliahh

I can't code, don't blame me thanks

Documentation

Index

Constants

View Source
const BASE_GENSHIN_UI_URL = "https://enka.network/ui/"
View Source
const BASE_SR_UI_URL = "https://enka.network/ui/hsr/"
View Source
const BASE_URL = "https://enka.network/api/"

Variables

View Source
var MaintenanceError error = errors.New("enka-network-api-go: The API is currently in maintenance")

Functions

This section is empty.

Types

type EnkaNetworkAPI

type EnkaNetworkAPI interface {
	Data() data.EnkaData
	Cache() cache.EnkaHttpCache
	StarRail() StarRailAPI
	Genshin() GenshinAPI

	SetUserAgent(userAgent string)
}

func New

func New(userAgent string, httpCache cache.EnkaHttpCache, loggers ...*slog.Logger) (EnkaNetworkAPI, error)

New creates a new EnkaNetworkAPI instance

Parameters:

userAgent: The User-Agent header for requests
cacheSupplier: A function that returns a cache instance
loggers: Optional custom loggers

Will also initialize the cache and localization

From the documentation:

Please set a custom User-Agent header with your requests so I can track them better and help you if needed.

See https://api.enka.network/ for API docs

func NewDefault added in v0.2.2

func NewDefault() (EnkaNetworkAPI, error)

NewDefaultUserAgent creates a new EnkaNetworkAPI instance with the default User-Agent header Consider using New or SetUserAgent instead

func WithCustomUserAgent added in v0.4.0

func WithCustomUserAgent(userAgent string) (EnkaNetworkAPI, error)

type GenshinAPI added in v0.4.0

type GenshinAPI interface {
	Fetch(uid string, showCaseInfo bool, success utils.Consumer[*genshin.RawGenshinUser], failure utils.Consumer[error])
	FetchAndReturn(uid string, showCaseInfo bool) (*genshin.RawGenshinUser, error)

	CharacterData(userCharacter *genshin.UserCharacter) *genshin.CharacterData
	CharacterDataById(uuid string) *genshin.CharacterData

	Icon(key string) string

	ProfileId(id int) string
	NameCard(nameCardId int) *genshin.NameCard
	Material(id int) *genshin.RawMaterial
}

type StarRailAPI added in v0.4.0

type StarRailAPI interface {
	Fetch(uid string, success utils.Consumer[*starrail.RawHonkaiUser], failure utils.Consumer[error])
	FetchAndReturn(uid string) (*starrail.RawHonkaiUser, error)

	CharacterData(userCharacter *starrail.UserCharacter) *starrail.CharacterData
	CharacterDataById(uuid string) *starrail.CharacterData

	RelicData(relic *starrail.Relic) *starrail.RelicData
	RelicDataById(relicId string) *starrail.RelicData

	LightConeData(lightCone *starrail.LightCone) *starrail.LightConeData
	LightConeDataById(lightConeId string) *starrail.LightConeData

	Icon(key string) string
	AvatarKey(avatarId string) string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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