Documentation
¶
Overview ¶
Package rsi provides a Go client for the Roberts Space Industries (RSI) API. It allows fetching information about Star Citizen users, organizations, ships, roadmaps, statistics, and more.
Index ¶
- Constants
- Variables
- func ConvertVal(val any, target string) any
- func HTTPFormatter(val any) string
- func RangeFormatter(min, max any) string
- type Client
- func (c *Client) GetOrganization(ctx context.Context, sid string) (*OrganizationData, error)
- func (c *Client) GetOrganizationMembers(ctx context.Context, sid string, page int, options map[string]any) ([]OrganizationMember, error)
- func (c *Client) GetPatchNotes(ctx context.Context) ([]PatchNote, error)
- func (c *Client) GetProgressTrackerInfo(ctx context.Context, teamSlug, dateMin, dateMax string) ([]map[string]any, error)
- func (c *Client) GetProgressTrackerTeams(ctx context.Context, dateMin, dateMax string) ([]map[string]any, error)
- func (c *Client) GetRoadmap(ctx context.Context, board, version string) ([]RoadmapRelease, error)
- func (c *Client) GetStarmapAffiliations(ctx context.Context, name string) ([]map[string]any, error)
- func (c *Client) GetStarmapCelestialObject(ctx context.Context, code string) ([]map[string]any, error)
- func (c *Client) GetStarmapSpecies(ctx context.Context, name string) ([]map[string]any, error)
- func (c *Client) GetStarmapStarSystem(ctx context.Context, code string) ([]map[string]any, error)
- func (c *Client) GetStarmapSystems(ctx context.Context, name string) ([]map[string]any, error)
- func (c *Client) GetStarmapTunnels(ctx context.Context, tid string) ([]map[string]any, error)
- func (c *Client) GetStats(ctx context.Context) (*StatsData, error)
- func (c *Client) GetTelemetry(ctx context.Context, timetable, version string) (map[string]any, error)
- func (c *Client) GetUser(ctx context.Context, handle string) (*UserProfile, error)
- func (c *Client) SearchShips(ctx context.Context, options map[string]any) ([]map[string]any, error)
- func (c *Client) SearchStarmap(ctx context.Context, query string) (*StarmapSearchResult, error)
- func (c *Client) SearchStarmapRoute(ctx context.Context, from, to, shipSize string) (*StarmapRouteResult, error)
- type Command
- type Connector
- func (c *Connector) Client() *http.Client
- func (c *Connector) ConvertPath(path string) string
- func (c *Connector) Get(ctx context.Context, path string, headers map[string]string) (*http.Response, error)
- func (c *Connector) Post(ctx context.Context, path string, body any, headers map[string]string) (*http.Response, error)
- func (c *Connector) Request(ctx context.Context, method, path string, body any, headers map[string]string) (*http.Response, error)
- type FocusInfo
- type HTTPError
- type Organization
- type OrganizationData
- type OrganizationFocus
- type OrganizationInfo
- type OrganizationMember
- type OrganizationMembers
- type PageInfo
- type ParseError
- type PatchNote
- type ProfileInfo
- type ProgressTracker
- type ProgressTrackerInfo
- type Roadmap
- type RoadmapCard
- type RoadmapCategory
- type RoadmapRelease
- type Ship
- type ShipData
- type StarmapAffiliations
- type StarmapCelestialObjects
- type StarmapRouteResult
- type StarmapRouteSearch
- type StarmapSearch
- type StarmapSearchResult
- type StarmapSpecies
- type StarmapStarSystems
- type StarmapSystems
- type StarmapTunnels
- type Stats
- type StatsData
- type Telemetry
- type TextContent
- type User
- type UserAffiliationInfo
- type UserProfile
- type VersionInfo
Constants ¶
const ( // BaseURL is the RSI API base URL BaseURL = "https://robertsspaceindustries.com" // DefaultTimeout is the default request timeout DefaultTimeout = 5 * time.Second )
Variables ¶
Functions ¶
func ConvertVal ¶
ConvertVal converts an interface{} value to a specific type based on target Mimics Python's convert_val method from ICommand
func HTTPFormatter ¶
HTTPFormatter formats values for HTTP query parameters Mimics Python's http_formatter method
func RangeFormatter ¶
RangeFormatter formats min/max range values as "min,max"
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides a convenient interface to RSI APIs
func NewClient ¶
func NewClient() *Client
NewClient creates a new RSI API client with default settings
func NewClientWithConnector ¶
NewClientWithConnector creates a client with a custom connector Useful for testing with VCR or custom transport configurations
func NewClientWithTimeout ¶
NewClientWithTimeout creates a new RSI API client with a custom timeout
func (*Client) GetOrganization ¶
GetOrganization fetches organization details by SID
func (*Client) GetOrganizationMembers ¶
func (c *Client) GetOrganizationMembers(ctx context.Context, sid string, page int, options map[string]any) ([]OrganizationMember, error)
GetOrganizationMembers fetches organization members with pagination and filters
func (*Client) GetPatchNotes ¶
GetPatchNotes fetches Star Citizen patch notes
func (*Client) GetProgressTrackerInfo ¶
func (c *Client) GetProgressTrackerInfo(ctx context.Context, teamSlug, dateMin, dateMax string) ([]map[string]any, error)
GetProgressTrackerInfo fetches detailed progress tracker info for a team
func (*Client) GetProgressTrackerTeams ¶
func (c *Client) GetProgressTrackerTeams(ctx context.Context, dateMin, dateMax string) ([]map[string]any, error)
GetProgressTrackerTeams fetches progress tracker teams data
func (*Client) GetRoadmap ¶
GetRoadmap fetches roadmap data for a specific board board: "starcitizen" or "squadron42" version: optional version filter
func (*Client) GetStarmapAffiliations ¶
GetStarmapAffiliations fetches starmap affiliations, optionally filtered by name or code
func (*Client) GetStarmapCelestialObject ¶
func (c *Client) GetStarmapCelestialObject(ctx context.Context, code string) ([]map[string]any, error)
GetStarmapCelestialObject fetches celestial object details by code
func (*Client) GetStarmapSpecies ¶
GetStarmapSpecies fetches starmap species, optionally filtered by name or code
func (*Client) GetStarmapStarSystem ¶
GetStarmapStarSystem fetches star system details by code
func (*Client) GetStarmapSystems ¶
GetStarmapSystems fetches starmap systems, optionally filtered by name
func (*Client) GetStarmapTunnels ¶
GetStarmapTunnels fetches starmap tunnels, optionally filtered by ID
func (*Client) GetTelemetry ¶
func (c *Client) GetTelemetry(ctx context.Context, timetable, version string) (map[string]any, error)
GetTelemetry fetches telemetry data timetable: "DAY", "WEEK", or "MONTH" version: game version (e.g., "3.17.0")
func (*Client) SearchShips ¶
SearchShips searches for ships with the given criteria
func (*Client) SearchStarmap ¶
SearchStarmap performs a starmap search
func (*Client) SearchStarmapRoute ¶
func (c *Client) SearchStarmapRoute(ctx context.Context, from, to, shipSize string) (*StarmapRouteResult, error)
SearchStarmapRoute finds routes between systems shipSize: S, M, or L
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector handles HTTP transport to RSI endpoints
func NewConnectorWithClient ¶
NewConnectorWithClient creates a connector with a custom HTTP client Useful for testing with VCR or custom transport configurations
func (*Connector) ConvertPath ¶
ConvertPath joins a path with the base URL
func (*Connector) Get ¶
func (c *Connector) Get(ctx context.Context, path string, headers map[string]string) (*http.Response, error)
Get performs a GET request
type Organization ¶
type Organization struct {
// contains filtered or unexported fields
}
Organization fetches organization information
func NewOrganization ¶
func NewOrganization(sid string) *Organization
NewOrganization creates a new organization fetcher
func (*Organization) Execute ¶
func (o *Organization) Execute(ctx context.Context) (*OrganizationData, error)
Execute fetches organization data using concurrent goroutines
type OrganizationData ¶
type OrganizationData struct {
URL string `json:"url"`
SID string `json:"sid"`
Logo string `json:"logo,omitempty"`
Name string `json:"name,omitempty"`
Focus OrganizationFocus `json:"focus"`
Banner string `json:"banner,omitempty"`
Headline TextContent `json:"headline"`
History TextContent `json:"history"`
Manifesto TextContent `json:"manifesto"`
Charter TextContent `json:"charter"`
// Fields from search
Href string `json:"href,omitempty"`
Archetype string `json:"archetype,omitempty"`
Lang string `json:"lang,omitempty"`
Commitment string `json:"commitment,omitempty"`
Recruiting bool `json:"recruiting"`
Roleplay bool `json:"roleplay"`
Members int `json:"members"`
}
OrganizationData represents complete organization information
type OrganizationFocus ¶
type OrganizationFocus struct {
Primary FocusInfo `json:"primary"`
Secondary FocusInfo `json:"secondary"`
}
OrganizationFocus contains primary and secondary focus
type OrganizationInfo ¶
type OrganizationInfo struct {
Image string `json:"image,omitempty"`
Name string `json:"name,omitempty"`
SID string `json:"sid,omitempty"`
Rank string `json:"rank,omitempty"`
Stars int `json:"stars"`
}
OrganizationInfo contains main organization details
type OrganizationMember ¶
type OrganizationMember struct {
Handle string `json:"handle"`
Display string `json:"display,omitempty"`
Stars int `json:"stars"`
Rank string `json:"rank,omitempty"`
Roles []string `json:"roles"`
Image string `json:"image,omitempty"`
}
OrganizationMember represents a single organization member
type OrganizationMembers ¶
type OrganizationMembers struct {
// contains filtered or unexported fields
}
OrganizationMembers fetches organization members
func NewOrganizationMembers ¶
func NewOrganizationMembers(sid string, page int, options map[string]any) *OrganizationMembers
NewOrganizationMembers creates a new organization members fetcher
func (*OrganizationMembers) Execute ¶
func (om *OrganizationMembers) Execute(ctx context.Context) ([]OrganizationMember, error)
Execute fetches organization members
type ParseError ¶
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
type PatchNote ¶
type PatchNote struct {
Link string `json:"link"`
Title string `json:"title"`
Version string `json:"version,omitempty"`
Image string `json:"image,omitempty"`
}
PatchNote represents a single patch note entry
type ProfileInfo ¶
type ProfileInfo struct {
Page PageInfo `json:"page"`
ID string `json:"id,omitempty"`
Display string `json:"display,omitempty"`
Handle string `json:"handle,omitempty"`
Badge string `json:"badge,omitempty"`
BadgeImage string `json:"badge_image,omitempty"`
Image string `json:"image,omitempty"`
Enlisted string `json:"enlisted,omitempty"`
Location map[string]string `json:"location,omitempty"`
Fluency []string `json:"fluency,omitempty"`
Website string `json:"website,omitempty"`
Bio string `json:"bio,omitempty"`
}
ProfileInfo contains user profile details
type ProgressTracker ¶
type ProgressTracker struct {
// contains filtered or unexported fields
}
ProgressTracker fetches progress tracker teams
func NewProgressTracker ¶
func NewProgressTracker(dateMin, dateMax string) *ProgressTracker
NewProgressTracker creates a new progress tracker fetcher
type ProgressTrackerInfo ¶
type ProgressTrackerInfo struct {
// contains filtered or unexported fields
}
ProgressTrackerInfo fetches detailed progress tracker info for a specific team
func NewProgressTrackerInfo ¶
func NewProgressTrackerInfo(slug, dateMin, dateMax string) *ProgressTrackerInfo
NewProgressTrackerInfo creates a new progress tracker info fetcher
type Roadmap ¶
type Roadmap struct {
// contains filtered or unexported fields
}
Roadmap fetches roadmap data for Star Citizen or Squadron 42
func NewRoadmap ¶
NewRoadmap creates a new Roadmap fetcher
type RoadmapCard ¶
type RoadmapCard struct {
ID int `json:"id"`
CategoryID int `json:"category_id"`
CategoryName string `json:"category_name"`
Name string `json:"name"`
Description string `json:"description"`
}
RoadmapCard represents a single roadmap card
type RoadmapCategory ¶
RoadmapCategory represents a category
type RoadmapRelease ¶
type RoadmapRelease struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Cards []RoadmapCard `json:"cards"`
}
RoadmapRelease represents a release containing multiple cards
type Ship ¶
type Ship struct {
// contains filtered or unexported fields
}
Ship fetches ship information with search and pagination
type ShipData ¶
type ShipData struct {
ID int `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Price float64 `json:"price"`
}
ShipData represents a single ship
type StarmapAffiliations ¶
type StarmapAffiliations struct {
// contains filtered or unexported fields
}
StarmapAffiliations fetches and filters starmap affiliations
func NewStarmapAffiliations ¶
func NewStarmapAffiliations(name string) *StarmapAffiliations
NewStarmapAffiliations creates a new starmap affiliations fetcher
type StarmapCelestialObjects ¶
type StarmapCelestialObjects struct {
// contains filtered or unexported fields
}
StarmapCelestialObjects fetches celestial object details by code
func NewStarmapCelestialObjects ¶
func NewStarmapCelestialObjects(code string) *StarmapCelestialObjects
NewStarmapCelestialObjects creates a new celestial objects fetcher
type StarmapRouteResult ¶
type StarmapRouteResult struct {
Shortest any `json:"shortest"`
LeastJumps any `json:"leastjumps"`
}
StarmapRouteResult contains route search results
type StarmapRouteSearch ¶
type StarmapRouteSearch struct {
// contains filtered or unexported fields
}
StarmapRouteSearch finds routes between systems
func NewStarmapRouteSearch ¶
func NewStarmapRouteSearch(from, to, shipSize string) *StarmapRouteSearch
NewStarmapRouteSearch creates a new route search shipSize: S, M, or L
func (*StarmapRouteSearch) Execute ¶
func (r *StarmapRouteSearch) Execute(ctx context.Context) (*StarmapRouteResult, error)
Execute performs a route search
type StarmapSearch ¶
type StarmapSearch struct {
// contains filtered or unexported fields
}
StarmapSearch performs a starmap search
func NewStarmapSearch ¶
func NewStarmapSearch(search string) *StarmapSearch
NewStarmapSearch creates a new starmap search
func (*StarmapSearch) Execute ¶
func (s *StarmapSearch) Execute(ctx context.Context) (*StarmapSearchResult, error)
Execute performs a starmap search
type StarmapSearchResult ¶
type StarmapSearchResult struct {
Systems []map[string]any `json:"systems"`
Objects []map[string]any `json:"objects"`
}
StarmapSearchResult contains search results
type StarmapSpecies ¶
type StarmapSpecies struct {
// contains filtered or unexported fields
}
StarmapSpecies fetches and filters starmap species
func NewStarmapSpecies ¶
func NewStarmapSpecies(name string) *StarmapSpecies
NewStarmapSpecies creates a new starmap species fetcher
type StarmapStarSystems ¶
type StarmapStarSystems struct {
// contains filtered or unexported fields
}
StarmapStarSystems fetches star system details by code
func NewStarmapStarSystems ¶
func NewStarmapStarSystems(code string) *StarmapStarSystems
NewStarmapStarSystems creates a new star systems fetcher
type StarmapSystems ¶
type StarmapSystems struct {
// contains filtered or unexported fields
}
StarmapSystems fetches and filters starmap systems
func NewStarmapSystems ¶
func NewStarmapSystems(name string) *StarmapSystems
NewStarmapSystems creates a new starmap systems fetcher
type StarmapTunnels ¶
type StarmapTunnels struct {
// contains filtered or unexported fields
}
StarmapTunnels fetches and filters starmap tunnels
func NewStarmapTunnels ¶
func NewStarmapTunnels(tid string) *StarmapTunnels
NewStarmapTunnels creates a new starmap tunnels fetcher
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
Stats fetches general RSI statistics
type StatsData ¶
type StatsData struct {
Fans int `json:"fans"`
Funds float64 `json:"funds"`
Fleet *int `json:"fleet"` // Can be null
CurrentLive *string `json:"current_live"`
CurrentPTU *string `json:"current_ptu"`
CurrentETF *string `json:"current_etf"`
}
StatsData represents RSI statistics
type Telemetry ¶
type Telemetry struct {
// contains filtered or unexported fields
}
Telemetry fetches telemetry data for Star Citizen
func NewTelemetry ¶
NewTelemetry creates a new Telemetry fetcher timetable: "DAY", "WEEK", or "MONTH" version: Star Citizen game version (e.g., "3.17.0")
type TextContent ¶
type TextContent struct {
HTML string `json:"html,omitempty"`
Plaintext string `json:"plaintext,omitempty"`
}
TextContent contains HTML and plaintext versions
type User ¶
type User struct {
// contains filtered or unexported fields
}
User fetches RSI user/citizen information
type UserAffiliationInfo ¶
type UserAffiliationInfo struct {
SID string `json:"sid,omitempty"`
Name string `json:"name,omitempty"`
Rank string `json:"rank,omitempty"`
Stars int `json:"stars"`
Image string `json:"image,omitempty"`
}
UserAffiliationInfo represents an affiliated organization
type UserProfile ¶
type UserProfile struct {
Profile ProfileInfo `json:"profile"`
Organization OrganizationInfo `json:"organization"`
Affiliation []UserAffiliationInfo `json:"affiliation"`
}
UserProfile represents a user's profile information
type VersionInfo ¶
type VersionInfo struct {
// contains filtered or unexported fields
}
VersionInfo fetches Star Citizen patch notes
func NewVersionInfo ¶
func NewVersionInfo() *VersionInfo
NewVersionInfo creates a new VersionInfo fetcher