Documentation
¶
Index ¶
- type APIError
- type AuthenticatedUser
- type Client
- type ClientOption
- func WithAPIKey(key string) ClientOption
- func WithBaseURLGames(u string) ClientOption
- func WithBaseURLGroups(u string) ClientOption
- func WithBaseURLUsers(u string) ClientOption
- func WithCookie(cookie string) ClientOption
- func WithHTTPClient(hc *http.Client) ClientOption
- func WithOAuthToken(token string) ClientOption
- func WithUserAgent(ua string) ClientOption
- type Creator
- type ErrorResponse
- type FavoritesCount
- type Game
- type GameServer
- type GameVotes
- type GamesService
- func (s *GamesService) GetByUniverseIDs(ctx context.Context, ids []int64) ([]*Game, *Response, error)
- func (s *GamesService) GetFavoritesCount(ctx context.Context, universeID int64) (*FavoritesCount, *Response, error)
- func (s *GamesService) GetVotes(ctx context.Context, universeID int64) (*GameVotes, *Response, error)
- func (s *GamesService) ListByGroupID(ctx context.Context, groupID int64, opts *ListOptions) ([]*Game, *Response, error)
- func (s *GamesService) ListByUserID(ctx context.Context, userID int64, opts *ListOptions) ([]*Game, *Response, error)
- func (s *GamesService) ListServers(ctx context.Context, placeID int64, serverType string, opts *ServerListOptions) ([]*GameServer, *Response, error)
- type GetByIDsRequest
- type GetByUsernamesRequest
- type Group
- type GroupMember
- type GroupMemberUser
- type GroupOwner
- type GroupRole
- type GroupRolesResponse
- type GroupSearchOptions
- type GroupSearchResult
- type GroupSummary
- type GroupsService
- func (s *GroupsService) Get(ctx context.Context, groupID int64) (*Group, *Response, error)
- func (s *GroupsService) GetByIDs(ctx context.Context, groupIDs []int64) ([]*Group, *Response, error)
- func (s *GroupsService) ListMembers(ctx context.Context, groupID int64, opts *ListOptions) ([]*GroupMember, *Response, error)
- func (s *GroupsService) ListRoles(ctx context.Context, groupID int64) ([]*GroupRole, *Response, error)
- func (s *GroupsService) ListUserMemberships(ctx context.Context, userID int64) ([]*UserGroupMembership, *Response, error)
- func (s *GroupsService) ListUsersInRole(ctx context.Context, groupID, roleSetID int64, opts *ListOptions) ([]*GroupMember, *Response, error)
- func (s *GroupsService) Search(ctx context.Context, opts *GroupSearchOptions) ([]*GroupSearchResult, *Response, error)
- type ListOptions
- type Rate
- type RateLimitError
- type Response
- type SearchOptions
- type ServerListOptions
- type User
- type UserByUsername
- type UserGroupMembership
- type UserSearchResult
- type UsernameHistory
- type UsersService
- func (s *UsersService) Get(ctx context.Context, userID int64) (*User, *Response, error)
- func (s *UsersService) GetAuthenticated(ctx context.Context) (*AuthenticatedUser, *Response, error)
- func (s *UsersService) GetByIDs(ctx context.Context, body *GetByIDsRequest) ([]*User, *Response, error)
- func (s *UsersService) GetByUsernames(ctx context.Context, body *GetByUsernamesRequest) ([]*UserByUsername, *Response, error)
- func (s *UsersService) ListUsernameHistory(ctx context.Context, userID int64, opts *ListOptions) ([]*UsernameHistory, *Response, error)
- func (s *UsersService) Search(ctx context.Context, opts *SearchOptions) ([]*UserSearchResult, *Response, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
Code int `json:"code"`
Message string `json:"message"`
UserFacingMessage string `json:"userFacingMessage"`
}
APIError represents a single error object in the Roblox error envelope.
type AuthenticatedUser ¶
type AuthenticatedUser struct {
ID int64 `json:"id"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
}
AuthenticatedUser represents the currently authenticated user.
type Client ¶
type Client struct {
UserAgent string
BaseURLUsers *url.URL
BaseURLGames *url.URL
BaseURLGroups *url.URL
Users *UsersService
Games *GamesService
Groups *GroupsService
// contains filtered or unexported fields
}
Client manages communication with the Roblox API.
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
NewClient creates a new Roblox API client with the given options.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is a functional option for configuring a Client.
func WithAPIKey ¶
func WithAPIKey(key string) ClientOption
WithAPIKey sets the x-api-key header for all requests.
func WithBaseURLGames ¶
func WithBaseURLGames(u string) ClientOption
WithBaseURLGames overrides the games API base URL (useful for testing).
func WithBaseURLGroups ¶
func WithBaseURLGroups(u string) ClientOption
WithBaseURLGroups overrides the groups API base URL (useful for testing).
func WithBaseURLUsers ¶
func WithBaseURLUsers(u string) ClientOption
WithBaseURLUsers overrides the users API base URL (useful for testing).
func WithCookie ¶
func WithCookie(cookie string) ClientOption
WithCookie sets the .ROBLOSECURITY cookie for all requests.
func WithHTTPClient ¶
func WithHTTPClient(hc *http.Client) ClientOption
WithHTTPClient sets the underlying HTTP client.
func WithOAuthToken ¶
func WithOAuthToken(token string) ClientOption
WithOAuthToken sets the Authorization: Bearer header for all requests.
func WithUserAgent ¶
func WithUserAgent(ua string) ClientOption
WithUserAgent sets the User-Agent header.
type Creator ¶
type Creator struct {
ID int64 `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
IsRNVAccount bool `json:"isRNVAccount"`
HasVerifiedBadge bool `json:"hasVerifiedBadge"`
}
Creator represents the creator of a game.
type ErrorResponse ¶
ErrorResponse is returned when the API responds with a non-2xx status.
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
type FavoritesCount ¶
type FavoritesCount struct {
FavoritesCount int64 `json:"favoritesCount"`
}
FavoritesCount holds the favorites count for a game.
type Game ¶
type Game struct {
ID int64 `json:"id"`
RootPlaceID int64 `json:"rootPlaceId"`
Name string `json:"name"`
Description string `json:"description"`
SourceName string `json:"sourceName"`
SourceDescription string `json:"sourceDescription"`
Creator Creator `json:"creator"`
Price *int64 `json:"price"`
AllowedGearGenres []string `json:"allowedGearGenres"`
AllowedGearCategories []string `json:"allowedGearCategories"`
IsGenreEnforced bool `json:"isGenreEnforced"`
CopyingAllowed bool `json:"copyingAllowed"`
Playing int64 `json:"playing"`
Visits int64 `json:"visits"`
MaxPlayers int `json:"maxPlayers"`
Created string `json:"created"`
Updated string `json:"updated"`
StudioAccessToApisAllowed bool `json:"studioAccessToApisAllowed"`
CreateVipServersAllowed bool `json:"createVipServersAllowed"`
UniverseAvatarType string `json:"universeAvatarType"`
Genre string `json:"genre"`
IsAllGenre bool `json:"isAllGenre"`
IsFavoritedByUser bool `json:"isFavoritedByUser"`
FavoritedCount int64 `json:"favoritedCount"`
}
Game represents a Roblox game (universe).
type GameServer ¶
type GameServer struct {
ID string `json:"id"`
MaxPlayers int `json:"maxPlayers"`
Playing int `json:"playing"`
PlayerTokens []string `json:"playerTokens"`
FPS float64 `json:"fps"`
Ping float64 `json:"ping"`
Name string `json:"name"`
VIPServerId int64 `json:"vipServerId"`
AccessCode string `json:"accessCode"`
}
GameServer represents an active game server instance.
type GameVotes ¶
type GameVotes struct {
ID int64 `json:"id"`
UpVotes int64 `json:"upVotes"`
DownVotes int64 `json:"downVotes"`
}
GameVotes holds upvote/downvote counts for a game.
type GamesService ¶
type GamesService service
GamesService handles communication with the Games API. https://games.roblox.com/
func (*GamesService) GetByUniverseIDs ¶
func (s *GamesService) GetByUniverseIDs(ctx context.Context, ids []int64) ([]*Game, *Response, error)
GetByUniverseIDs returns games for a list of universe IDs (batch, up to 100).
func (*GamesService) GetFavoritesCount ¶
func (s *GamesService) GetFavoritesCount(ctx context.Context, universeID int64) (*FavoritesCount, *Response, error)
GetFavoritesCount returns the favorites count for a universe.
func (*GamesService) GetVotes ¶
func (s *GamesService) GetVotes(ctx context.Context, universeID int64) (*GameVotes, *Response, error)
GetVotes returns the vote counts for a universe.
func (*GamesService) ListByGroupID ¶
func (s *GamesService) ListByGroupID(ctx context.Context, groupID int64, opts *ListOptions) ([]*Game, *Response, error)
ListByGroupID returns games created by a group with cursor-based pagination.
func (*GamesService) ListByUserID ¶
func (s *GamesService) ListByUserID(ctx context.Context, userID int64, opts *ListOptions) ([]*Game, *Response, error)
ListByUserID returns games created by a user with cursor-based pagination.
func (*GamesService) ListServers ¶
func (s *GamesService) ListServers(ctx context.Context, placeID int64, serverType string, opts *ServerListOptions) ([]*GameServer, *Response, error)
ListServers returns servers for a place. serverType is "Public" or "Friend".
type GetByIDsRequest ¶
type GetByIDsRequest struct {
UserIDs []int64 `json:"userIds"`
ExcludeBannedUsers bool `json:"excludeBannedUsers"`
}
GetByIDsRequest is the request body for GetByIDs.
type GetByUsernamesRequest ¶
type GetByUsernamesRequest struct {
Usernames []string `json:"usernames"`
ExcludeBannedUsers bool `json:"excludeBannedUsers"`
}
GetByUsernamesRequest is the request body for GetByUsernames.
type Group ¶
type Group struct {
ID int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Owner *GroupOwner `json:"owner"`
MemberCount int64 `json:"memberCount"`
IsBuildersClubOnly bool `json:"isBuildersClubOnly"`
PublicEntryAllowed bool `json:"publicEntryAllowed"`
HasVerifiedBadge bool `json:"hasVerifiedBadge"`
}
Group represents a Roblox group.
type GroupMember ¶
type GroupMember struct {
User GroupMemberUser `json:"user"`
Role GroupRole `json:"role"`
}
GroupMember represents a member of a group.
type GroupMemberUser ¶
type GroupMemberUser struct {
ID int64 `json:"userId"`
Username string `json:"username"`
DisplayName string `json:"displayName"`
HasVerifiedBadge bool `json:"hasVerifiedBadge"`
}
GroupMemberUser is the user portion of a GroupMember.
type GroupOwner ¶
type GroupOwner struct {
ID int64 `json:"userId"`
Username string `json:"username"`
DisplayName string `json:"displayName"`
HasVerifiedBadge bool `json:"hasVerifiedBadge"`
}
GroupOwner represents the owner of a group.
type GroupRole ¶
type GroupRole struct {
ID int64 `json:"id"`
Name string `json:"name"`
Rank int `json:"rank"`
MemberCount int64 `json:"memberCount"`
}
GroupRole represents a role within a group.
type GroupRolesResponse ¶
GroupRolesResponse wraps the roles response from /v1/groups/{groupId}/roles.
type GroupSearchOptions ¶
type GroupSearchOptions struct {
ListOptions
Keyword string `url:"keyword,omitempty"`
}
GroupSearchOptions extends ListOptions with a keyword.
type GroupSearchResult ¶
type GroupSearchResult struct {
ID int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
MemberCount int64 `json:"memberCount"`
PublicEntryAllowed bool `json:"publicEntryAllowed"`
Created string `json:"created"`
Updated string `json:"updated"`
HasVerifiedBadge bool `json:"hasVerifiedBadge"`
}
GroupSearchResult represents a group returned from search.
type GroupSummary ¶
type GroupSummary struct {
ID int64 `json:"id"`
Name string `json:"name"`
MemberCount int64 `json:"memberCount"`
HasVerifiedBadge bool `json:"hasVerifiedBadge"`
}
GroupSummary is a minimal group representation used in memberships.
type GroupsService ¶
type GroupsService service
GroupsService handles communication with the Groups API. https://groups.roblox.com/
func (*GroupsService) GetByIDs ¶
func (s *GroupsService) GetByIDs(ctx context.Context, groupIDs []int64) ([]*Group, *Response, error)
GetByIDs returns groups for a list of group IDs (batch, up to 100).
func (*GroupsService) ListMembers ¶
func (s *GroupsService) ListMembers(ctx context.Context, groupID int64, opts *ListOptions) ([]*GroupMember, *Response, error)
ListMembers returns members of a group with cursor-based pagination.
func (*GroupsService) ListRoles ¶
func (s *GroupsService) ListRoles(ctx context.Context, groupID int64) ([]*GroupRole, *Response, error)
ListRoles returns all roles in a group.
func (*GroupsService) ListUserMemberships ¶
func (s *GroupsService) ListUserMemberships(ctx context.Context, userID int64) ([]*UserGroupMembership, *Response, error)
ListUserMemberships returns all groups a user belongs to.
func (*GroupsService) ListUsersInRole ¶
func (s *GroupsService) ListUsersInRole(ctx context.Context, groupID, roleSetID int64, opts *ListOptions) ([]*GroupMember, *Response, error)
ListUsersInRole returns users in a specific role with cursor-based pagination.
func (*GroupsService) Search ¶
func (s *GroupsService) Search(ctx context.Context, opts *GroupSearchOptions) ([]*GroupSearchResult, *Response, error)
Search searches for groups by keyword with cursor-based pagination.
type ListOptions ¶
type ListOptions struct {
Limit int `url:"limit,omitempty"`
Cursor string `url:"cursor,omitempty"`
SortOrder string `url:"sortOrder,omitempty"`
}
ListOptions specifies cursor-based pagination parameters.
type RateLimitError ¶
RateLimitError is returned when the API returns 429.
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
type SearchOptions ¶
type SearchOptions struct {
ListOptions
Keyword string `url:"keyword,omitempty"`
}
SearchOptions extends ListOptions with a search keyword.
type ServerListOptions ¶
type ServerListOptions struct {
ListOptions
ExcludeFullGames bool `url:"excludeFullGames,omitempty"`
}
ServerListOptions extends ListOptions for server listing.
type User ¶
type User struct {
ID int64 `json:"id"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
Description string `json:"description"`
IsBanned bool `json:"isBanned"`
Created string `json:"created"`
HasVerifiedBadge bool `json:"hasVerifiedBadge"`
}
User represents a Roblox user account.
type UserByUsername ¶
type UserByUsername struct {
ID int64 `json:"id"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
RequestedUsername string `json:"requestedUsername"`
HasVerifiedBadge bool `json:"hasVerifiedBadge"`
}
UserByUsername is the result entry from the GetByUsernames batch call.
type UserGroupMembership ¶
type UserGroupMembership struct {
Group GroupSummary `json:"group"`
Role GroupRole `json:"role"`
}
UserGroupMembership represents a user's membership in a group.
type UserSearchResult ¶
type UserSearchResult struct {
ID int64 `json:"id"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
HasVerifiedBadge bool `json:"hasVerifiedBadge"`
PreviousUsernames []string `json:"previousUsernames"`
}
UserSearchResult represents a user returned from search.
type UsernameHistory ¶
type UsernameHistory struct {
Name string `json:"name"`
}
UsernameHistory represents a previous username entry.
type UsersService ¶
type UsersService service
UsersService handles communication with the Users API. https://users.roblox.com/
func (*UsersService) GetAuthenticated ¶
func (s *UsersService) GetAuthenticated(ctx context.Context) (*AuthenticatedUser, *Response, error)
GetAuthenticated returns the currently authenticated user.
func (*UsersService) GetByIDs ¶
func (s *UsersService) GetByIDs(ctx context.Context, body *GetByIDsRequest) ([]*User, *Response, error)
GetByIDs returns users matching the given IDs (batch, up to 100).
func (*UsersService) GetByUsernames ¶
func (s *UsersService) GetByUsernames(ctx context.Context, body *GetByUsernamesRequest) ([]*UserByUsername, *Response, error)
GetByUsernames returns users matching the given usernames (batch, up to 100).
func (*UsersService) ListUsernameHistory ¶
func (s *UsersService) ListUsernameHistory(ctx context.Context, userID int64, opts *ListOptions) ([]*UsernameHistory, *Response, error)
ListUsernameHistory returns the username history for a user with cursor-based pagination.
func (*UsersService) Search ¶
func (s *UsersService) Search(ctx context.Context, opts *SearchOptions) ([]*UserSearchResult, *Response, error)
Search searches for users by keyword with cursor-based pagination.