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.
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::Client;
let client = Client::new();
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 fn new() -> Self
pub fn new() -> Self
Used to interface with Roblox.com endpoints.
Contains any necessary authentication and security tokens, as well as the reqwest client.
sourcepub fn with_reqwest_client(reqwest_client: Client) -> Self
pub fn with_reqwest_client(reqwest_client: Client) -> Self
Creates a new Client providing a custom reqwest::Client.
Custom reqwest::Clients are used for configuring proxies.
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.
sourcepub fn set_roblosecurity(&self, roblosecurity: String)
pub fn set_roblosecurity(&self, roblosecurity: String)
Sets the Roblosecurity string for the client.
Example
use roboat::Client;
let client = Client::new();
client.set_roblosecurity("my_roblosecurity".to_string());sourcepub fn roblosecurity(&self) -> Option<String>
pub fn roblosecurity(&self) -> Option<String>
Returns a copy of the Roblosecurity stored in the client.
If the Roblosecurity has not been set, None is returned.
Example
use roboat::Client;
let client = Client::new();
client.set_roblosecurity("my_roblosecurity".to_string());
let roblosecurity = client.roblosecurity();
assert_eq!(roblosecurity, Some("my_roblosecurity".to_string()));source§impl Client
impl Client
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::Client;
let client = Client::new();
client.set_roblosecurity("my_roblosecurity".to_string());
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),
}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::Client;
let client = Client::new();
client.set_roblosecurity("my_roblosecurity".to_string());
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::Client;
let client = Client::new();
client.set_roblosecurity("my_roblosecurity".to_string());
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::Client;
let client = Client::new();
client.set_roblosecurity("my_roblosecurity".to_string());
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);