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. 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

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::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

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§

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::ClientBuilder;

const ROBLOSECURITY: &str = "roblosecurity";

let client = ClientBuilder::new().roblosecurity(ROBLOSECURITY.to_string()).build();

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::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);
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::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);
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::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),
}
source

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

source

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

source

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

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

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