pub struct Client { /* private fields */ }Expand description
A client used for making requests to the Roblox API.
The client stores the roblosecurity cookie, X-CSRF-TOKEN header, and an HTTPS client to send web requests. The client also caches the user id, username, and display name of the user.
Constructed using a ClientBuilder.
Construction Examples
Without Roblosecurity or a Custom Reqwest Client
use roboat::ClientBuilder;
let client = ClientBuilder::new().build();With a Roblosecurity
use roboat::ClientBuilder;
const ROBLOSECURITY: &str = "roblosecurity";
let client = ClientBuilder::new().roblosecurity(ROBLOSECURITY.to_string()).build();With a Custom Reqwest Client
use roboat::ClientBuilder;
let reqwest_client = reqwest::Client::new();
let client = ClientBuilder::new().reqwest_client(reqwest_client).build();With a Roblosecurity and a Custom Reqwest Client
use roboat::ClientBuilder;
const ROBLOSECURITY: &str = "roblosecurity";
let reqwest_client = reqwest::Client::new();
let client = ClientBuilder::new().roblosecurity(ROBLOSECURITY.to_string()).reqwest_client(reqwest_client).build();Implementations§
source§impl Client
impl Client
sourcepub async fn item_details(
&self,
items: Vec<ItemArgs>
) -> Result<Vec<ItemDetails>, RoboatError>
pub async fn item_details( &self, items: Vec<ItemArgs> ) -> Result<Vec<ItemDetails>, RoboatError>
Grabs details of one or more items from https://catalog.roblox.com/v1/catalog/items/details.
Notes
- Does not require a valid roblosecurity.
- This endpoint will accept up to 120 items at a time.
- Will repeat once if the x-csrf-token is invalid.
Argument Notes
- The
idparameter is that acts differently for this endpoint than others. If theitem_typeisItemType::Asset, thenidis the item ID. Otherwise, if theitem_typeisItemType::Bundle, thenidis the bundle ID.
Example
use roboat::catalog::avatar_catalog::ItemArgs;
use roboat::catalog::avatar_catalog::ItemType;
use roboat::ClientBuilder;
let client = ClientBuilder::new().build();
let asset = ItemArgs {
item_type: ItemType::Asset,
id: 1365767,
};
let bundle = ItemArgs {
item_type: ItemType::Bundle,
id: 39,
};
let items = vec![asset, bundle];
let details = client.item_details(items).await?;
println!("Item Name: {}", details[0].name);
println!("Bundle Name: {}", details[1].name);source§impl Client
impl Client
sourcepub async fn user_id(&self) -> Result<u64, RoboatError>
pub async fn user_id(&self) -> Result<u64, RoboatError>
Returns the user id of the user. If the user id is not cached, it will be fetched from Roblox first.
sourcepub async fn username(&self) -> Result<String, RoboatError>
pub async fn username(&self) -> Result<String, RoboatError>
Returns the username of the user. If the username is not cached, it will be fetched from Roblox first.
sourcepub async fn display_name(&self) -> Result<String, RoboatError>
pub async fn display_name(&self) -> Result<String, RoboatError>
Returns the display name of the user. If the display name is not cached, it will be fetched from Roblox first.
source§impl Client
impl Client
sourcepub async fn robux(&self) -> Result<u64, RoboatError>
pub async fn robux(&self) -> Result<u64, RoboatError>
Grabs robux count of the current account from https://economy.roblox.com/v1/users/{user_id}/currency.
Notes
- Requires a valid roblosecurity.
Example
use roboat::ClientBuilder;
const ROBLOSECURITY: &str = "roblosecurity";
let client = ClientBuilder::new().roblosecurity(ROBLOSECURITY.to_string()).build();
let robux = client.robux().await?;
println!("Robux: {}", robux);sourcepub async fn resellers(
&self,
item_id: u64,
limit: Limit,
cursor: Option<String>
) -> Result<(Vec<Listing>, Option<String>), RoboatError>
pub async fn resellers( &self, item_id: u64, limit: Limit, cursor: Option<String> ) -> Result<(Vec<Listing>, Option<String>), RoboatError>
Grabs resellers of an item from https://economy.roblox.com/v1/assets/{item_id}/resellers?cursor={cursor}&limit={limit}.
Notes
- Requires a valid roblosecurity.
Argument Notes
- The cursor is used to get the a certain page of results. If you want the starting page, use
None. - The default
limitisLimit::Ten.
Return Value Notes
- The first value is a vector of reseller listings.
- The second value is the cursor for the next page of results. If there are no more pages, this will be
None.
Example
use roboat::Limit;
use roboat::ClientBuilder;
const ROBLOSECURITY: &str = "roblosecurity";
let client = ClientBuilder::new().roblosecurity(ROBLOSECURITY.to_string()).build();
let item_id = 1365767;
let limit = Limit::Ten;
let cursor = None;
let (resellers, next_page_cursor) = client.resellers(item_id, limit, cursor).await?;
println!("Lowest Price for Item {}: {}", item_id, resellers[0].price);sourcepub async fn user_sales(
&self,
limit: Limit,
cursor: Option<String>
) -> Result<(Vec<UserSale>, Option<String>), RoboatError>
pub async fn user_sales( &self, limit: Limit, cursor: Option<String> ) -> Result<(Vec<UserSale>, Option<String>), RoboatError>
Grabs user sales from https://economy.roblox.com/v2/users/{user_id}/transactions?transactionType=Sale&cursor={cursor}&limit={limit}.
Notes
- Requires a valid roblosecurity.
Argument Notes
- The cursor is used to get the a certain page of results. If you want the starting page, use
None. - The default
limitisLimit::Hundred.
Return Value Notes
- The first value is a vector of user sales.
- The second value is the cursor for the next page of results. If there are no more pages, this will be
None.
Example
use roboat::Limit;
use roboat::ClientBuilder;
const ROBLOSECURITY: &str = "roblosecurity";
let client = ClientBuilder::new().roblosecurity(ROBLOSECURITY.to_string()).build();
let limit = Limit::Ten;
let cursor = None;
let (user_sales, next_page_cursor) = client.user_sales(limit, cursor).await?;
let sale_amount = user_sales.len();
let total_robux_earned = user_sales
.iter()
.map(|sale| sale.robux_received)
.sum::<u64>();
println!("Robux gained from last {} sales: {}", sale_amount, total_robux_earned);sourcepub async fn put_limited_on_sale(
&self,
item_id: u64,
uaid: u64,
price: u64
) -> Result<(), RoboatError>
pub async fn put_limited_on_sale( &self, item_id: u64, uaid: u64, price: u64 ) -> Result<(), RoboatError>
Puts a limited item on sale using the endpoint https://economy.roblox.com/v1/assets/{item_id}/resellable-copies/{uaid}.
Notes
- Requires a valid roblosecurity.
- Will repeat once if the x-csrf-token is invalid.
Return Value Notes
- Will return
Ok(())if the item was successfully put on sale.
Example
use roboat::ClientBuilder;
const ROBLOSECURITY: &str = "roblosecurity";
let client = ClientBuilder::new().roblosecurity(ROBLOSECURITY.to_string()).build();
let item_id = 123456789;
let uaid = 987654321;
let price = 5000;
match client.put_limited_on_sale(item_id, uaid, price).await {
Ok(_) => println!("Successfully put item on sale!"),
Err(e) => println!("Error: {}", e),
}sourcepub async fn take_limited_off_sale(
&self,
item_id: u64,
uaid: u64
) -> Result<(), RoboatError>
pub async fn take_limited_off_sale( &self, item_id: u64, uaid: u64 ) -> Result<(), RoboatError>
Takes a limited item off sale using the endpoint https://economy.roblox.com/v1/assets/{item_id}/resellable-copies/{uaid}.
Notes
- Requires a valid roblosecurity.
- Will repeat once if the x-csrf-token is invalid.
Return Value Notes
- Will return
Ok(())if the item was successfully taken off sale.
Example
use roboat::ClientBuilder;
const ROBLOSECURITY: &str = "roblosecurity";
let client = ClientBuilder::new().roblosecurity(ROBLOSECURITY.to_string()).build();
let item_id = 123456789;
let uaid = 987654321;
match client.take_limited_off_sale(item_id, uaid).await {
Ok(_) => println!("Successfully took item off sale!"),
Err(e) => println!("Error: {}", e),
}source§impl Client
impl Client
sourcepub async fn register_presence(&self) -> Result<(), RoboatError>
pub async fn register_presence(&self) -> Result<(), RoboatError>
Registers presence on the website (makes you appear to be online). Endpoint called is https://presence.roblox.com/v1/presence/register-app-presence
Notes
- Requires a valid roblosecurity.
- Will repeat once if the x-csrf-token is invalid.
- Normally repeats every 15 seconds when viewing the Roblox homepage.
Return Value Notes
- Will return
Ok(())if presence was successfully registered.
Example
use roboat::ClientBuilder;
const ROBLOSECURITY: &str = "roblosecurity";
let client = ClientBuilder::new().roblosecurity(ROBLOSECURITY.to_string()).build();
match client.register_presence().await {
Ok(_) => println!("Successfully registered presence!"),
Err(e) => println!("Error: {}", e),
}source§impl Client
impl Client
sourcepub async fn trades(
&self,
trade_type: TradeType,
limit: Limit,
cursor: Option<String>
) -> Result<Vec<Trade>, RoboatError>
pub async fn trades( &self, trade_type: TradeType, limit: Limit, cursor: Option<String> ) -> Result<Vec<Trade>, RoboatError>
Returns a list of trades using the endpoint https://trades.roblox.com/v1/{trade_type}.
Notes
- Requires a valid roblosecurity.
- Trades are ordered newest to oldest.
Example
use roboat::ClientBuilder;
use roboat::trades::TradeType;
use roboat::Limit;
const ROBLOSECURITY: &str = "roblosecurity";
let client = ClientBuilder::new().roblosecurity(ROBLOSECURITY.to_string()).build();
let trade_type = TradeType::Inbound;
let limit = Limit::Ten;
let cursor = None;
let trades = client.trades(trade_type, limit, cursor).await?;
println!("Inbound Trade #1 Partner: {}", trades[0].partner.username);source§impl Client
impl Client
sourcepub async fn user_search(
&self,
keyword: String
) -> Result<Vec<User>, RoboatError>
pub async fn user_search( &self, keyword: String ) -> Result<Vec<User>, RoboatError>
Searches for a user using https://users.roblox.com/v1/users/search.
Notes
- Does not require a valid roblosecurity.
- HOWEVER, if a valid roblosecurity is not provided then there will be a very low rate limit.
- The cursors in this response are not used as using them is currently broken.
- Limits are not used for the same reason (the endpoint does not respect them).
Example
use roboat::ClientBuilder;
const ROBLOSECURITY: &str = "roblosecurity";
const KEYWORD: &str = "linkmon";
let client = ClientBuilder::new().roblosecurity(ROBLOSECURITY.to_string()).build();
let keyword = "linkmon".to_string();
let users = client.user_search(keyword).await?;
println!("Found {} users.", users.len());
for user in users {
println!("{}: {}", user.username, user.user_id);
}