Struct roboat::Client

source ·
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

source

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 id parameter is that acts differently for this endpoint than others. If the item_type is ItemType::Asset, then id is the item ID. Otherwise, if the item_type is ItemType::Bundle, then id is 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

source

pub fn new() -> Self

Used to interface with Roblox.com endpoints.

Contains any necessary authentication and security tokens, as well as the reqwest client.

source

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.

source

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.

source

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.

source

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

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());
source

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

pub fn set_xcsrf(&self, xcsrf: String)

Sets the xcsrf token of the client.

Example
use roboat::Client;

let client = Client::new();
client.set_xcsrf("my_xcsrf".to_string());
source

pub fn xcsrf(&self) -> String

Returns a copy of the xcsrf stored in the client.

Example
use roboat::Client;

let client = Client::new();
client.set_xcsrf("my_xcsrf".to_string());
let xcsrf = client.xcsrf();
assert_eq!(xcsrf, "my_xcsrf".to_string());
source§

impl Client

source

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

source

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);
source

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 limit is Limit::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);
source

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 limit is Limit::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);

Trait Implementations§

source§

impl Debug for Client

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Client

source§

fn default() -> Client

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more