enkanetworkapigo

package module
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: MIT Imports: 17 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 = 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)
	GetUserAgent() string
	HttpClient() *http.Client
}

func New

func New(opts ...Option) (EnkaNetworkAPI, error)

New creates a new EnkaNetworkAPI instance 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

type GenshinAPI added in v0.4.0

type GenshinAPI interface {
	Fetch(uid string, showCaseInfo bool, success utils.Consumer[*genshin.RawUser], failure utils.Consumer[error])
	FetchAndReturn(uid string, showCaseInfo bool) (*genshin.RawUser, 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 HttpUserAgentInterceptor added in v0.5.6

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

func (*HttpUserAgentInterceptor) RoundTrip added in v0.5.6

func (uai *HttpUserAgentInterceptor) RoundTrip(request *http.Request) (*http.Response, error)

type Option added in v0.5.6

type Option func(e *enkaNetworkAPI)

func WithCustomUserAgent added in v0.4.0

func WithCustomUserAgent(userAgent string) Option

func WithHttpCache added in v0.5.6

func WithHttpCache(cache cache.EnkaHttpCache) Option

func WithHttpClient added in v0.5.6

func WithHttpClient(httpClient *http.Client) Option

func WithLogger added in v0.6.0

func WithLogger(logger zerolog.Logger) Option

type StarRailAPI added in v0.4.0

type StarRailAPI interface {
	Fetch(uid string, success utils.Consumer[*starrail.RawUser], failure utils.Consumer[error])
	FetchAndReturn(uid string) (*starrail.RawUser, 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