Categorygithub.com/post04/rustchance-api-wrapper
modulepackage
0.0.0-20210721054707-f966d08f09e4
Repository: https://github.com/post04/rustchance-api-wrapper.git
Documentation: pkg.go.dev

# README

Explanation

This package is an API wrapper for the popular rust skin gambling website rustchance. I made this package because I wanted to play around with automatically doing things on rustchance but didn't see ANY public API documentation or ANY talk about one.

TODO

  • Search for more authorization required socket data
  • Search for more authorization required http/s endpoints
  • Add all /api/account/history/ API urls to the wrapper

Note

The rustchance API is not at all documented or even meant for this type of use (non web), with that being said, rustchance has some obscure variable names that I had to go through and figure out myself. With that this wrapper is subject to human error and if you find any problems in the wrapper or in my understanding of the API please open a github issue or make a pull request!

P.S. This is what the owner of rustchance said when he saw this project, if you need a code of conduct to stay abiding by rustchance TOS just read this. image

# Packages

No description provided by the author

# Functions

New returns a *Session and err Token is your auth token, this can be left empty, you only need a token for account specific things Rooms is a list of rooms to join, assumed to join all but you can set specific rooms.

# Constants

AccountEarningsURL is the url to get the total account earning of an account.
AccountLeaderboardURL is the url for the account leader board.
AccountProfileURL is the url to get the account profile, right now we use this to get the json of user information.
CrashGameURL is the url to get information about a coinflip game.
FaucetClaimURL is the url to claim the free 3 cent faucet.
HistoryAPIURL is the url to fetch the history of various gamemodes.
ProvefairSerialURL is the url to check the validity of a "provably fair" action.
RedeemCodeURL is the url to redeem a sponsor code.
SocketURL Is the url for the websocket that rustchance.com uses.
TicketsLeaderboardURL is the url for the tickets leaderboard data.

# Variables

AccountJSONRegex is the regex to pull the json out of the profile HTML.

# Structs

AccountInfo is the information of an account.
AccountLeaderboard is the information about an account leaderboard.
ChatMessage is the data for the chat_message event through the socket.
ChatMessageData is the expected data field for the chat_message socket event.
ChatMessageProfile is the profile that is making a chat message, this includes things like steamID, steam avatar, rust chance id, etc.
ChatRooms is the struct for the event we use to see when to set our current room, when this event fires you should chance your room to "en", "tr", or "ru".
ChatStats is the event for chat_stats in the socket.
ChatStatsData includes the steam stability status and how many users are online in the current chat.
CoinflipDeleteGame is the event for when a coinflip game is deleted, the Data is the ID for the game.
CoinflipGameStatus updates the game status for a coinflip game, the data is CoinflipGameStatusData.
CoinflipGameStatusData is the data for a coinflip game, this includes the ID of the game, serial/seed information, and which side won as well as if the game is finished.
CoinflipHistory is the history for coinflip games.
CoinflipList is a list of coinflip games, finished or not.
CoinflipListData is a slice of CoinflipNewGameData because the data there is also applicable to this event.
CoinflipNewGame is the event for coinflip_newgame.
CoinflipNewGameData is the data for a new game of coinflip, this contains the game ID, how much money is on the line, etc.
CoinflipUpdateGame is used for when a coinflip game is updating status.
CoinflipUpdateGameData is the data for when a coinflip game updates, rather that be a user joining or the game finishing.
CrashCashOut is used when someone cashes out of a crash game, taking their profit and leaving.
CrashCashOutData contains information like how much money the person leaving made and I think their rustchance user id.
CrashEnd is used when a crash game is done, includes information about the game.
CrashEndData contains information about the ended crash game like the game id and crash point.
CrashGame is a response from the API for a crash game.
CrashList is a list of crash games, should only be triggered once but due to lack of documentation I cannot say for sure.
CrashListData is the data for the CrashList payload, includes previous crash games and the current active crash game.
CrashListDataHistory contains information about previous games of crash, the game id and crashpoint.
CrashListDataSettings are the settings for the current crash.
CrashMultipleBets is used when a new bet(s) are added to the current crash game.
CrashMultipleBetsData contains data about the bet being added NOTE: Some of this data may be incorrect, rustchance has no documentation so I had to reverse everything my self so some things may be wrong.
CrashNew is a new crash game, it contains infromation about a new crash game but over all it's really just useful for knowing a new game start and not really useful for the information in the payload.
CrashNewData has data about a new crash game being started, bets *should* always be nil.
CrashStart has information about a new crash game starting.
CrashStartData has information about the state of the crash game and the time the game started (which is a string for god knows what reason).
CrashTick is a new tick of crash, it's the current crash position.
Current is the data for the current/active low jackpot game.
Deposits contains information for each deposit including what items they deposited and infromation about their account.
EnterRouletteData contains data to enter a roulette game.
FaucetResponse is the response from attempting to claim the faucet.
Game is the current crash game (used in the CrashList payload).
History is data for a previous low jackpot game, there's a lot of data here but most of it speaks for it self.
InProgress is used for a mines game that's in progress.
JackpotHistory is a list of previous jackpot games.
JackpotList is the list of highroller jackpot games, should only be triggered once on startup but due to lack of documentation I cannot tell for sure.
JackpotNewDeposit contains data about a new highrollers jackpot deposit of skins, includes information about the user adding skins and the skins being added.
JackpotNewGame contains data about a new highrollers jackpot game.
JackpotStartTimer is used to tell that the current highrollers jackpot game timer is starting, the data should be the Unix time that the timer is done and the game gets rolled (with lack of documentation it's hard to tell).
Joinable is used for a mines game that's joinable.
LowJackpotList is a list of low jackpot games including the current active game and previous games, this should only be triggered once on startup but with lack of documentation I can't know for sure.
LowJackpotListData contains data like previous low jackpot games, the current game, and if the current game is rolling.
LowJackpotNewDeposit contains information about when a new deposit is added to a lowjackpot game.
LowJackpotNewGame contains data for a new Lowjackpot game starting.
LowJackpotNewGameData contains data about the previous(old) game and the current(new) game.
LowJackpotStartTimer is used to tell when a low jackpot timer is starting, I believe the data is the Unix time when the timer is done and the lowjackpot is rolled but with no documentation it's hard to tell.
MinesBeginTimer is used for telling when a game is going to start (I think, no documentation makes it hard).
MinesBeginTimerData contains the game id and the time that the game is going to start (probably Unix but with no documentation I can't say for sure).
MinesGameStarted is used to tell when a mines game is started, the data is the game id.
MinesGameStarting is when a mines game is starting.
MinesGameStartingData is the data for a mines game that's starting, includes the game id and number of bombs and number of tiles.
MinesList is a list of mine games, this should only be triggered once on startup but due to lack of documentation I can't say for sure.
MinesListData is the data for a mines list, has games in progess and games that are joinable currently.
MinesListSettings is the settings for a mines game.
MinesNewGame is the payload for when a new mines game is made, includes stuff like the current players and how much the mines game is worth.
MinesNewGameData is the data for a new mines game, includes how much the game is worth and the game id.
MinesNewPlayer represents a new player joining a mines game.
MinesNewPlayerData is the data for a mines game when a new player joins, as well as the updated pot and the player data such as name and avatar as well as other things.
MinesWinner represents a win in the mines gamemode.
MinesWinnerData is the winner of a mines game, the Winner field is probably the rustchance.com player id (rustchance has 0 documentation so I can't be sure).
NewGame is the data for the current(new) lowjackpot game.
OldGame contains data for the previous(old) lowjackpot game.
Payload is the typical payload, this should be able to be used 99% of the time when writing to the socket.
Player is the struct that describes account information about the Player joining a mines game NOTE: Because of the lack of documentation and the terrible variable names in the json payload, I could have gotten some of this wrong.
Players is used in a few places but it's similar to the Player struct except it has a field Empty, the field empty basically means "is the field filled by a player or is this slot open".
ProvablyFair is the response from ProvefairSerialURL.
RedeemCodeResponse is the response from attempting to redeem a sponsor code.
RouletteList lists out the data for roulette games.
RouletteNewGame contains data about a new game of roulette.
RouletteRoll contains information about the result of a reoulette game as well as the ID of the next game.
RouletteRollData contains information like the next game and the result of this game.
Session is the main struct for the session.
Settings contains information about the Low jackpot settings, there's a lot of stuff here but most of it speaks for it self.
ShopRules is the expected payload from the shop_rules socket event.
ShopRulesData is the expected data field of the shop_rules socket event.
Side represents either red or blue side on a coinflip match.
SupplyDropsJoinable is the expected payload from the supply-drops_joinable socket event.
SupplyDropsList is the expected payload from the supply-drops_list socket event.
SupplyDropsListData is the expected data field from the supply-drops_list socket event.
SupplyDropsPlayers says how many players are currently in the supply drop.
SupplyDropWinner says who won a supply drop, this contains all sorts of data about the user who won including their steam ID and steam avatar.
SupplyDropWinnerData contains information about the supply drop winner including timeleft (idk why this is here, seems to always be 0) and the winner.
TicketsLeaderboard is the data for the current users in the tickets leaderboard.
TicketsLeaderboardResult contains data for the tickets leaderboard.
TotalWagered is the information for the total amount an account has wagered and won.
TotalWageredResult contains how much money an account has wagered and how much an account has won (this can be used to calculate total earnings).
User represents a user in the ticket leaderboard.
UserSetPoints updates the client on how much money the user has.
Winner is the winner of a supply drop.