### Run Basic Usage Example Source: https://github.com/kibbewater/wf-market/blob/main/README.md Executes the basic usage example for the wf-market crate, which does not require authentication. This is a good starting point for testing the client. ```bash # Basic usage (no auth required) cargo run --example basic_usage ``` -------------------------------- ### Run Authenticated Examples Source: https://github.com/kibbewater/wf-market/blob/main/README.md Executes authenticated examples for the wf-market crate, requiring WFM_EMAIL and WFM_PASSWORD environment variables to be set. Use for testing order creation, session persistence, and WebSocket support. ```bash # Authenticated examples (set WFM_EMAIL and WFM_PASSWORD) export WFM_EMAIL="your@email.com" export WFM_PASSWORD="your_password" cargo run --example create_orders cargo run --example session_persistence cargo run --example websocket --features websocket # Generate JWT token for testing (saves to .env) cargo run --example update_token ``` -------------------------------- ### Rust Caching Example Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/items.md This example shows how to load, use, and save a cache for market data. It initializes an `ApiCache`, builds a `Client` with it, and then saves the updated cache to a JSON file. This is useful for applications that need to maintain state between restarts or reduce API load. ```rust use wf_market::{Client, ApiCache, SerializableCache}; use std::fs; use std::time::Duration; async fn example() -> wf_market::Result<()> { // Load cache from disk (or create new) let mut cache = match fs::read_to_string("cache.json") { Ok(json) => serde_json::from_str::(&json)? .into_api_cache(), Err(_) => ApiCache::new(), }; // Build client using cache (uses cached items if < 1 day old) let client = Client::builder() .build_with_cache(&mut cache) .await?; // Items are loaded from cache or API println!("Loaded {} items", client.items().len()); // For long-running apps, refresh periodically (after game updates) client.revalidate_items().await?; // Save cache for next time let serializable = SerializableCache::from(&cache); fs::write("cache.json", serde_json::to_string(&serializable)?) Ok(()) } ``` -------------------------------- ### CreateOrder Examples Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/types.md Illustrates how to construct different types of sell and buy orders using the CreateOrder builder pattern. ```rust // Simple sell order let order = CreateOrder::sell("nikana_prime_set", 100, 1); ``` ```rust // Mod order with rank let order = CreateOrder::sell("serration", 50, 1).with_mod_rank(10); ``` ```rust // Hidden order let order = CreateOrder::buy("mesa_prime_set", 200, 1).hidden(); ``` ```rust // Sculpture with stars let order = CreateOrder::sell("ayatan_anasa_sculpture", 25, 1) .with_sculpture_stars(2, 4); ``` -------------------------------- ### Cross-Platform Analysis Configuration Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Example demonstrating how to configure the client for multiple platforms to perform cross-platform analysis. ```rust let platforms = [Platform::Pc, Platform::Ps4, Platform::Xbox]; for platform in &platforms { let client = Client::builder() .platform(*platform) .build() .await?; let orders = client.get_orders("item").await?; println!("Orders on {}: {}", platform, orders.len()); } ``` -------------------------------- ### UpdateOrder Examples Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/types.md Demonstrates how to create update requests for market orders, showing how to modify individual fields or multiple fields at once. ```rust // Update just the price let update = UpdateOrder::new().platinum(90); ``` ```rust // Update price and quantity let update = UpdateOrder::new() .platinum(85) .quantity(10); ``` ```rust // Hide the order let update = UpdateOrder::new().visible(false); ``` ```rust // Update sculpture stars let update = UpdateOrder::new() .amber_stars(2) .cyan_stars(4); ``` -------------------------------- ### Example: Using ApiCache with Client Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Demonstrates loading, using, and saving an ApiCache with the Client. It shows how to initialize the cache from a file, build the client with it, and refresh it if stale. ```rust use wf_market::{Client, ApiCache, SerializableCache}; use std::time::Duration; async fn main() -> wf_market::Result<()> { // Load cache from file let mut cache = match std::fs::read_to_string("cache.json") { Ok(json) => serde_json::from_str::(&json)? .into_api_cache(), Err(_) => ApiCache::new(), }; // Build with cache (uses cached items if < 1 day old) let client = Client::builder() .build_with_cache(&mut cache) .await?; println!("Loaded {} items", client.items().len()); // For long-running apps, refresh periodically if cache.has_fresh_items(Duration::from_secs(12 * 60 * 60)) { client.revalidate_items().await?; } // Save cache for next time let serializable = SerializableCache::from(&cache); std::fs::write("cache.json", serde_json::to_string(&serializable)?) Ok(()) } ``` -------------------------------- ### Localized Application Configuration Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Example configuration for localized applications, setting the client language to German. ```rust let client = Client::builder() .language(Language::German) .build() .await?; ``` -------------------------------- ### Create a ClientBuilder Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Use `Client::builder()` to start configuring the API client. This method returns a `ClientBuilder` instance. ```rust pub fn builder() -> ClientBuilder ``` -------------------------------- ### Quick Start: wf-market Client Usage Source: https://github.com/kibbewater/wf-market/blob/main/README.md Demonstrates creating an unauthenticated client, accessing loaded items, fetching orders for an item, and logging in for authenticated operations. Includes creating a sell order. ```rust use wf_market::{Client, Credentials, CreateOrder}; #[tokio::main] async fn main() -> wf_market::Result<()> { // Create an unauthenticated client (fetches items automatically) let client = Client::builder().build().await?; // Items are already loaded - access them directly println!("Loaded {} items", client.items().len()); // Get orders for an item let orders = client.get_orders("nikana_prime_set").await?; for order in orders.iter().take(5) { // Orders have direct item access via get_item() if let Some(item) = order.get_item() { println!("{}: {}p for {}", order.user.ingame_name, order.order.platinum, item.name()); } } // Login for authenticated operations let creds = Credentials::new( "your@email.com", "password", Credentials::generate_device_id(), ); let client = client.login(creds).await?; // Create an order let order = client.create_order( CreateOrder::sell("nikana_prime_set", 100, 1) ).await?; println!("Created order: {}", order.id()); Ok(()) } ``` -------------------------------- ### Serialization Examples for Credentials Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/types.md Demonstrates how to serialize Credentials, both with and without the password included. The 'with_password()' method is used to opt-in to including the password. ```rust let creds = Credentials::new("user@example.com", "password", "device-id"); // Password excluded (safe) let safe = serde_json::to_string(&creds).unwrap(); // Password included (for encrypted storage only) let full = serde_json::to_string(&creds.with_password()).unwrap(); ``` -------------------------------- ### Get Items Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Fetch a list of all available items. Refer to the Items API for more information. ```rust client.items() ``` -------------------------------- ### ApiErrorResponse Example Usage Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/errors.md Demonstrates how to create and use an ApiErrorResponse, including accessing request and field errors. ```rust let response = ApiErrorResponse { api_version: "2.0".into(), error: ApiErrorDetails { request: Some(vec!["Item not found".into()]), inputs: Some(HashMap::from([ ("item_id".into(), vec!["Invalid item ID".into()]), ])), }, }; assert_eq!(response.request_errors(), vec!["Item not found"]); assert_eq!(response.field_errors("item_id"), vec!["Invalid item ID"]); assert!(response.has_validation_errors()); ``` -------------------------------- ### Client::builder() Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Creates a new client builder for configuring the API client. This is the starting point for creating a `Client` instance. ```APIDOC ## Client::builder() ### Description Create a new client builder for configuring the API client. ### Returns - `ClientBuilder` - A `ClientBuilder` instance for fluent configuration. ### Example ```rust use wf_market::{Client, Platform, Language}; let client = Client::builder() .platform(Platform::Ps4) .language(Language::German) .build() .await?; ``` ``` -------------------------------- ### Personal Tools Configuration Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Example configuration for personal tools, using PS4 platform, English language, and the standard rate limit. ```rust let client = Client::builder() .platform(Platform::Ps4) .language(Language::English) .rate_limit(3) // Standard rate limit .build() .await?; ``` -------------------------------- ### Get My Profile Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Fetch the profile details for the currently authenticated user. Refer to the Users API. ```rust client.me() ``` -------------------------------- ### Install wf-market Crate Source: https://github.com/kibbewater/wf-market/blob/main/README.md Add the wf-market crate to your Cargo.toml. Include the 'websocket' feature if real-time order updates are needed. ```toml [dependencies] wf-market = "0.2" # With WebSocket support wf-market = { version = "0.2", features = ["websocket"] } ``` -------------------------------- ### Get Item Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Retrieve details for a specific item using its slug. Consult the Items API. ```rust client.get_item(slug) ``` -------------------------------- ### Automatic Item Indexing Example Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Demonstrates the automatic fetching and indexing of items for efficient O(1) lookups. Items are fetched once upon client initialization and stored in an index. ```rust let client = Client::builder().build().await?; // Already loaded, no API call println!("Items: {}", client.items().len()); // O(1) lookup by slug if let Some(item) = client.get_item_by_slug("serration") { println!("Max rank: {}", item.as_mod().unwrap().max_rank()); } ``` -------------------------------- ### Error::api_details() Method Example Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/errors.md Shows how to retrieve detailed API error information from a general error type. ```rust match some_api_call().await { Err(e) => { if let Some(details) = e.api_details() { eprintln!("API error details: {:?}", details); } } Ok(result) => {}, } ``` -------------------------------- ### Bot and Automation Configuration Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Example configuration for bots and automation, using PC platform, English language, enabled cross-play, and conservative rate limiting. ```rust let client = Client::builder() .platform(Platform::Pc) .language(Language::English) .crossplay(true) .rate_limit(2) // Conservative rate limiting .build() .await?; ``` -------------------------------- ### Error::is_retryable() Method Example Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/errors.md Demonstrates checking if an error is retryable, typically for rate limiting or network issues. ```rust match api_call().await { Err(e) if e.is_retryable() => { println!("Retryable error, will retry..."); } Err(e) => { eprintln!("Non-retryable error: {}", e); } Ok(result) => {}, } ``` -------------------------------- ### Basic Usage - Public API Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Provides a fundamental example of using the wf-market client to fetch public order data for a given item. This snippet requires the `tokio` runtime and demonstrates basic client building and order retrieval. ```rust use wf_market::Client; #[tokio::main] async fn main() -> wf_market::Result<()> { // Build client (fetches items automatically) let client = Client::builder().build().await?; // Get orders for an item let orders = client.get_orders("nikana_prime_set").await?; for order in &orders { println!("{} @ {}p", order.user.ingame_name, order.order.platinum); } Ok(()) } ``` -------------------------------- ### Handling NotFound Errors in Rust Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/errors.md Example of how to match and handle the `Error::NotFound` variant in Rust. It demonstrates accessing the description of the missing resource. ```rust match client.get_orders("nonexistent_item").await { Err(Error::NotFound { resource }) => { eprintln!("Not found: {}", resource); } Ok(orders) => println!("Found {} orders", orders.len()), Err(e) => eprintln!("Error: {}", e), } ``` -------------------------------- ### Update User Profile Example Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/users.md Demonstrates how to update a user's profile using the UpdateProfile struct and client methods. Allows setting specific fields like 'about' or 'ingame_name' and 'locale'. ```rust let updated = client.update_profile( UpdateProfile::new() .about("Trading prime parts and relics!") ).await?; let updated = client.update_profile( UpdateProfile::new() .ingame_name("NewName123") .locale("de") ).await?; ``` -------------------------------- ### Get Client Configuration (Rust) Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Retrieves a reference to the client's configuration settings. This allows inspection of parameters like rate limits. ```rust pub fn config(&self) -> &ClientConfig ``` ```rust let rate_limit = client.config().rate_limit; ``` -------------------------------- ### Built-In Rate Limiting Example Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Shows how to configure and utilize the built-in rate limiting feature. The client automatically queues requests to adhere to the specified rate limit, preventing API throttling. ```rust let client = Client::builder() .rate_limit(3) // Max 3 requests per second .build() .await?; // These are automatically spaced to respect the rate limit for i in 0..100 { let order = client.get_order(&id).await?; // Queued automatically } ``` -------------------------------- ### Get User Orders by Slug Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/users.md Fetches all public orders for a given user slug. Use this to display a user's trading history. ```rust pub async fn get_user_orders(&self, user_slug: &str) -> Result> ``` ```rust let orders = client.get_user_orders("some_user_slug").await?; for order in &orders { println!( "{}: {} @ {}p", order.order_type, order.item_id, order.platinum ); } ``` -------------------------------- ### Manage Existing Orders Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Provides examples for updating an order's price, deleting an order, and closing an order to record a sale. These operations require an authenticated client and valid order IDs. ```rust use wf_market::UpdateOrder; #[tokio::main] async fn main() -> wf_market::Result<()> { let client = Client::from_credentials(creds).await?; let my_orders = client.my_orders().await?; for order in &my_orders { // Update price client.update_order( order.id(), UpdateOrder::new().platinum(95) ).await?; // Delete order client.delete_order(order.id()).await?; // Record a sale let transaction = client.close_order(order.id(), 1).await?; println!("Closed for {} platinum", transaction.platinum); } Ok(()) } ``` -------------------------------- ### Type-Safe Authentication Example Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Demonstrates how the client's type system enforces authentication levels at compile time. Unauthenticated clients can only access public endpoints, while authenticated clients can access private endpoints after a successful login. ```rust let unauth = Client::builder().build().await?; let orders = unauth.get_orders("item").await?; // ✓ Public endpoint // This doesn't compile // unauth.my_orders().await?; // ✗ Error: my_orders requires Authenticated // After login let auth = unauth.login(credentials).await?; auth.my_orders().await?; // ✓ Now it compiles ``` -------------------------------- ### Categorizing Items by Type Source: https://github.com/kibbewater/wf-market/blob/main/README.md Demonstrates how to use type-checking methods like `is_mod()`, `is_sculpture()`, and `is_regular()` to categorize items. Provides examples of accessing specific item data based on its type. ```rust let items = client.items(); for item in items.iter() { if item.is_mod() { let mod_view = item.as_mod().unwrap(); println!("{}: max rank {}", item.name(), mod_view.max_rank()); } else if item.is_sculpture() { let sculpture = item.as_sculpture().unwrap(); println!("{}: {} endo", item.name(), sculpture.calculate_endo(None, None)); } else if item.is_regular() { println!("{}: regular item", item.name()); } } ``` -------------------------------- ### Fallible Operation Examples Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/errors.md Examples of common fallible operations using the Result type alias. ```rust pub async fn get_orders(&self, slug: &str) -> Result> ``` ```rust pub async fn login(self, credentials: Credentials) -> Result> ``` ```rust pub async fn create_order(&self, request: CreateOrder) -> Result ``` -------------------------------- ### Configure and Build Client Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Demonstrates how to create a `ClientConfig` with custom settings and then build a `Client` instance using the builder pattern. ```rust let config = ClientConfig { platform: Platform::Ps4, language: Language::German, crossplay: false, rate_limit: 2, }; let client = Client::builder().config(config).build().await?; ``` -------------------------------- ### Handling Auth Errors in Rust Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/errors.md Example of how to match and handle the `Error::Auth` variant in Rust. It demonstrates accessing the error message and optional detailed response. ```rust match client.login(creds).await { Err(Error::Auth { message, details }) => { eprintln!("Login failed: {}", message); if let Some(error_details) = details { for field_error in error_details.field_errors("email") { eprintln!(" Email error: {}", field_error); } } } Err(e) => eprintln!("Unexpected error: {}", e), Ok(client) => println!("Logged in!"), } ``` -------------------------------- ### Calculate Endo for Sculpture Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/types.md Calculates the endo value for a sculpture, optionally with stars installed. Use when you need to determine the endo value based on installed stars or a fully socketed state. ```rust if let Some(sculpture) = item.as_sculpture() { let partial = sculpture.calculate_endo(Some(2), Some(1)); // 2 amber, 1 cyan let full = sculpture.calculate_endo(None, None); // fully socketed println!("Endo: {} (partial) / {} (full)", partial, full); } ``` -------------------------------- ### Set Up Credentials for Testing with .env Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Instructions for setting up credentials using a .env file for testing purposes, including loading variables with dotenv. ```bash # 1. Copy the example env file cp .env.example .env # 2. Edit .env with your credentials # WFM_EMAIL=your@email.com # WFM_PASSWORD=your_password # 3. Load in your tests dotenv::dotenv().ok(); let email = std::env::var("WFM_EMAIL").expect("Set WFM_EMAIL"); let password = std::env::var("WFM_PASSWORD").expect("Set WFM_PASSWORD"); ``` -------------------------------- ### Authenticate and Login with Credentials Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Demonstrates how to create credentials, build a client, and log in to access authenticated endpoints. Ensure you replace placeholder credentials with your actual email and password. ```rust use wf_market::{Client, Credentials}; #[tokio::main] async fn main() -> wf_market::Result<()> { // Create credentials let creds = Credentials::new( "your@email.com", "password", Credentials::generate_device_id(), ); // Build and login let client = Client::from_credentials(creds).await?; // Access authenticated endpoints let my_orders = client.my_orders().await?; println!("You have {} orders", my_orders.len()); Ok(()) } ``` -------------------------------- ### Error::is_auth_error() Method Example Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/errors.md Illustrates how to check if an error is related to authentication failure. ```rust match api_call().await { Err(e) if e.is_auth_error() => { println!("Please re-authenticate"); } Err(e) => eprintln!("Other error: {}", e), Ok(result) => {}, } ``` -------------------------------- ### Handling Api Errors in Rust Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/errors.md Example of how to match and handle the `Error::Api` variant in Rust. It shows how to access the HTTP status code, message, and the full API error response. ```rust match client.create_order(CreateOrder::sell("invalid_item", 100, 1)).await { Err(Error::Api { status, message, response }) => { eprintln!("API error ({}): {}", status, message); if let Some(resp) = response { for error in resp.request_errors() { eprintln!(" {}", error); } for (field, errors) in resp.error.inputs.iter().flatten() { eprintln!(" {}: {:?}", field, errors); } } } Ok(order) => println!("Order created: {}", order.id()), Err(e) => eprintln!("Other error: {}", e), } ``` -------------------------------- ### Login with Credentials Source: https://github.com/kibbewater/wf-market/blob/main/README.md Instantiate a client and log in using email, password, and a generated device ID. ```rust use wf_market::{Client, Credentials}; let creds = Credentials::new("email@example.com", "password", Credentials::generate_device_id()); let client = Client::builder().build().await?.login(creds).await?; ``` -------------------------------- ### Get My Orders Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Fetch the orders associated with the current user. Refer to the Orders API. ```rust client.my_orders() ``` -------------------------------- ### Build Client with Default Configuration Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Initializes an HTTP client using default configuration settings. ```rust let client = Client::builder().build().await?; // Uses: // - Platform::Pc // - Language::English // - crossplay: true // - rate_limit: 3 ``` -------------------------------- ### Troubleshooting Rate Limiting and Token Expiration Source: https://github.com/kibbewater/wf-market/blob/main/README.md Provides commands to resolve common issues like rate limiting and expired JWT tokens. Running `cargo run --example update_token` is the recommended solution for both. ```bash # Troubleshooting: # - "Rate limited": Wait 10-15 minutes, then run `cargo run --example update_token` # - "JWT token expired": Run `cargo run --example update_token` to refresh # - "Unknown error" on WebSocket: Use `--test-threads=1` to run tests serially ``` -------------------------------- ### Configure Client Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Use `ClientConfig` to set up the client's configuration. See the Configuration documentation. ```rust Use `ClientConfig` ``` -------------------------------- ### Set WFM_EMAIL Environment Variable Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Set the WFM_EMAIL environment variable for authentication in examples and integration tests. ```bash export WFM_EMAIL="user@example.com" ``` -------------------------------- ### Set Up and Run Integration Tests Source: https://github.com/kibbewater/wf-market/blob/main/README.md Configures and runs integration tests for the wf-market crate. This involves setting up credentials, generating a JWT token, and running tests serially to avoid WebSocket connection issues. ```bash # 1. Set up credentials cp .env.example .env # Edit .env with your email and password # 2. Generate a JWT token (avoids rate limiting) cargo run --example update_token # 3. Run integration tests (serially - server allows one WS connection) cargo test --all-features -- --ignored --nocapture --test-threads=1 ``` -------------------------------- ### Get User Profile Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Retrieve the profile information for a specific user by their slug. See the Users API. ```rust client.get_profile(slug) ``` -------------------------------- ### Create and Login Client with Credentials (Rust) Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md This asynchronous method creates a client and logs in using the provided credentials in a single step. It's suitable for initial authentication. ```rust pub async fn from_credentials( credentials: Credentials ) -> Result> ``` ```rust let creds = Credentials::new( "user@example.com", "password", Credentials::generate_device_id(), ); let client = Client::from_credentials(creds).await?; ``` -------------------------------- ### Get Client Language Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Retrieves the configured language for the client. This is useful for ensuring responses are in the expected language. ```rust println!("Language: {}", client.language()); ``` -------------------------------- ### Configure wf-market Client Source: https://github.com/kibbewater/wf-market/blob/main/README.md Sets up the client configuration, including platform, language, crossplay, and rate limits. This is essential for initializing the client for API requests. ```rust use wf_market::{Client, ClientConfig, Platform, Language}; let config = ClientConfig { platform: Platform::Pc, language: Language::English, crossplay: true, rate_limit: 3, // requests per second }; let client = Client::builder() .config(config) .build() .await?; ``` -------------------------------- ### Minimal Client Configuration Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Builds a basic client instance with default settings. Use this for simple operations like fetching orders. ```rust let client = Client::builder().build().await?; let orders = client.get_orders("serration").await?; ``` -------------------------------- ### get_listings Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/orders.md Get orders for an item without user information. This is more lightweight than get_orders() when you only need price/quantity data. ```APIDOC ## get_listings(slug: &str) ### Description Get orders for an item without user information. This is more lightweight than `get_orders()` when you only need price/quantity data. ### Method GET (implied) ### Endpoint /items/{slug}/listings (inferred) ### Parameters #### Path Parameters - **slug** (string) - Required - The item's slug ``` -------------------------------- ### Client::from_credentials_with_config Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Creates a client instance with custom configuration and logs in using provided credentials. This is an asynchronous operation. ```APIDOC ## Client::from_credentials_with_config ### Description Create a client with custom config and login in one step. ### Method `from_credentials_with_config` ### Endpoint N/A (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **credentials** (`Credentials`) - Required - Login credentials - **config** (`ClientConfig`) - Required - Custom client configuration ### Returns `Result>` - The authenticated client or an error. ### Example ```rust let config = ClientConfig { platform: Platform::Ps4, ..Default::default() }; let creds = Credentials::new("email", "password", Credentials::generate_device_id()); let client = Client::from_credentials_with_config(creds, config).await?; ``` ``` -------------------------------- ### Client::from_credentials Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Creates a client instance and logs in using provided credentials in a single step. This is an asynchronous operation. ```APIDOC ## Client::from_credentials ### Description Create a client and login in one step. ### Method `from_credentials` ### Endpoint N/A (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **credentials** (`Credentials`) - Required - Login credentials (password or token-based) ### Returns `Result>` - The authenticated client or an error. ### Errors - `Error::Auth` - If login fails (invalid credentials, etc.) - `Error::Network` - If the connection fails ### Example ```rust let creds = Credentials::new( "user@example.com", "password", Credentials::generate_device_id(), ); let client = Client::from_credentials(creds).await?; ``` ``` -------------------------------- ### Get Public Orders Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Retrieve a list of public orders for a given slug. Consult the Orders API documentation. ```rust client.get_orders(slug) ``` -------------------------------- ### Accessing Items via Client Source: https://github.com/kibbewater/wf-market/blob/main/README.md Demonstrates how to build a client and access items for O(1) lookups by ID or slug. Also shows how orders provide direct item access. ```rust let client = Client::builder().build().await?; println!("Total items: {}", client.items().len()); if let Some(item) = client.get_item_by_slug("serration") { println!("Found: {}", item.name()); if item.is_mod() { println!(" Max rank: {}", item.as_mod().unwrap().max_rank()); } else if item.is_regular() { println!(" Regular tradeable item"); } } let orders = client.get_orders("nikana_prime_set").await?; for order in &orders { if let Some(item) = order.get_item() { println!("{}: {}p", item.name(), order.order.platinum); } } ``` -------------------------------- ### Get Device ID Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Retrieves the unique device identifier associated with the client. This can be used for device-specific configurations or logging. ```rust println!("Device ID: {}", client.device_id()); ``` -------------------------------- ### Get Authentication Token Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Retrieves the JWT authentication token as a string slice. Useful for inspecting or logging the token. ```rust let token = client.token(); println!("Token length: {}", token.len()); ``` -------------------------------- ### Create Client with Custom Config and Credentials (Rust) Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Use this asynchronous method to create an authenticated client with custom configuration settings and login credentials simultaneously. Useful for specific platform or network requirements. ```rust pub async fn from_credentials_with_config( credentials: Credentials, config: ClientConfig, ) -> Result> ``` ```rust let config = ClientConfig { platform: Platform::Ps4, ..Default::default() }; let creds = Credentials::new("email", "password", Credentials::generate_device_id()); let client = Client::from_credentials_with_config(creds, config).await?; ``` -------------------------------- ### Get Credentials Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Retrieves the current authentication credentials, including the JWT token. This is useful for persisting user sessions. ```rust let creds = client.credentials(); let json = serde_json::to_string(creds)?; std::fs::write("session.json", json)?; ``` -------------------------------- ### Iterate Through All Available Platforms Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Shows how to iterate through all available platform options using the `all()` method. ```rust for platform in Platform::all() { println!("{}", platform); // Displays full name } ``` -------------------------------- ### Get Item by ID Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Retrieves a specific item using its unique identifier. Returns `None` if the item is not found. ```rust if let Some(item) = client.get_item_by_id("item-123") { println!("Found: {}", item.name()); } ``` -------------------------------- ### Build Client with Pre-loaded Items (Rust) Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Use this method to construct a client instance when you already have a collection of items loaded. This is a synchronous operation. ```rust pub fn build_with_items( self, items: Vec ) -> Result> ``` ```rust let items: Vec = load_items_from_file()?; let client = Client::builder().build_with_items(items)?; ``` -------------------------------- ### Build Client Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Use this method to construct a new client instance. Refer to the Client API documentation for more details. ```rust Client::builder()...build() ``` -------------------------------- ### Get Order by ID in Rust Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/orders.md Retrieves a single order using its unique identifier. Ensure the order ID is valid. ```rust pub async fn get_order(&self, id: &str) -> Result ``` ```rust let order = client.get_order("order-id-here").await?; println!("Order: {} @ {}p", order.item_id, order.platinum); ``` -------------------------------- ### get_orders Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/orders.md Get orders for an item, including seller/buyer information. Returns orders from users who were online in the last 7 days. ```APIDOC ## get_orders(slug: &str) ### Description Get orders for an item, including seller/buyer information. Returns orders from users who were online in the last 7 days. ### Method GET (implied) ### Endpoint /items/{slug}/orders (inferred) ### Parameters #### Path Parameters - **slug** (string) - Required - The item's URL-friendly identifier (e.g., "nikana_prime_set") ### Response #### Success Response (200) - **Vec** - Orders with associated user information. ### Errors: - `Error::NotFound` - If the item doesn't exist - `Error::Api` - If the API request fails - `Error::Network` - If the connection fails ``` -------------------------------- ### Access Configuration Values at Runtime Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Demonstrates how to access the client's configuration values, such as platform and language, after it has been built. ```rust let client = Client::builder() .platform(Platform::Ps4) .language(Language::German) .build() .await?; // Access the configuration let config = client.config(); println!("Platform: {}", client.platform()); println!("Language: {}", client.language()); println!("Config: {:?}", config); // Or get individual values let platform: Platform = client.platform(); let language: Language = client.language(); ``` -------------------------------- ### Client Configuration for Multi-Platform Analysis Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Builds multiple client instances, each configured for a different platform (PC, PS4, Xbox). This allows for comparative analysis across platforms. ```rust let mut results = HashMap::new(); for platform in [Platform::Pc, Platform::Ps4, Platform::Xbox].iter() { let client = Client::builder() .platform(*platform) .build() .await?; let orders = client.get_orders("serration").await?; results.insert(platform, orders.len()); } for (platform, count) in results { println!("{}: {} orders", platform, count); } ``` -------------------------------- ### Create Client for a Specific Platform Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Demonstrates creating an HTTP client configured for a specific platform, such as PlayStation 4. ```rust // Create a client configured for PlayStation 4 let client = Client::builder() .platform(Platform::Ps4) .build() .await?; // Platform affects which orders are fetched let orders = client.get_orders("nikana_prime_set").await?; // All returned orders are for PS4 (from PS4 users or PC users with cross-play enabled) ``` -------------------------------- ### Build Client with Platform and Language Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Configure the client with a specific platform and response language using the builder pattern. The `build()` method is called asynchronously. ```rust use wf_market::{Client, Platform, Language}; let client = Client::builder() .platform(Platform::Ps4) .language(Language::German) .build() .await?; ``` -------------------------------- ### Get Client Platform (Rust) Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Returns the platform enum value that the client is configured to interact with. This is useful for identifying the target environment. ```rust pub fn platform(&self) -> Platform ``` ```rust println!("Platform: {}", client.platform()); ``` -------------------------------- ### Configure Client with ClientBuilder Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Builds an HTTP client with specific configuration settings using the ClientBuilder. ```rust let client = Client::builder() .platform(Platform::Ps4) .language(Language::German) .crossplay(false) .rate_limit(2) .build() .await?; ``` -------------------------------- ### Get User Mastery Level Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/users.md Fetches a user's profile and displays their Mastery Rank if it is available. Checks if the `mastery_level` field is Some. ```rust let profile = client.get_profile("user_slug").await?; if let Some(mastery) = profile.mastery_level { println!("Mastery Rank: {}", mastery); } ``` -------------------------------- ### get_user_orders Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/orders.md Get all public orders for a specific user. Returns orders without user information since the user is already known. ```APIDOC ## get_user_orders(user_slug: &str) ### Description Get all public orders for a specific user. Returns orders without user information (since user is known). ### Method GET (implied) ### Endpoint /users/{user_slug}/orders (inferred) ### Parameters #### Path Parameters - **user_slug** (string) - Required - The user's slug (not the in-game name) ### Errors: - `Error::NotFound` - If the user doesn't exist - `Error::Api` - If the API request fails ``` -------------------------------- ### Set WFM_PASSWORD Environment Variable Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Set the WFM_PASSWORD environment variable for authentication in examples and integration tests. Use with caution and avoid in production. ```bash export WFM_PASSWORD="your_password" ``` -------------------------------- ### Configure Client with Platform Selection Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Builds a client instance configured to use a specific platform, such as PlayStation 4. ```rust use wf_market::{Client, Platform}; let client = Client::builder() .platform(Platform::Ps4) .build() .await?; ``` -------------------------------- ### Manage User Orders Source: https://github.com/kibbewater/wf-market/blob/main/README.md Demonstrates creating a new sell order, updating an existing order's price, deleting an order, and closing an order to record a sale. ```rust use wf_market::{CreateOrder, UpdateOrder}; // Get your orders let my_orders = client.my_orders().await?; // Create a sell order let order = client.create_order( CreateOrder::sell("nikana_prime_set", 100, 1).visible(true) ).await?; // Update order price client.update_order( order.id(), UpdateOrder::new().platinum(95) ).await?; // Delete order client.delete_order(order.id()).await?; // Close order (record a sale) let transaction = client.close_order(order.id(), 1).await?; ``` -------------------------------- ### Get Authenticated User's Orders in Rust Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/orders.md Fetches all orders associated with the currently authenticated user. Requires valid authentication credentials. ```rust pub async fn my_orders(&self) -> Result> ``` ```rust let client = Client::from_credentials(/* ... */).await?; let orders = client.my_orders().await?; for order in &orders { println!( "{}: {} @ {}p (qty: {})", order.id(), order.item_id(), order.platinum(), order.quantity() ); } ``` -------------------------------- ### Creating a Mod Order Source: https://github.com/kibbewater/wf-market/blob/main/README.md Shows how to create a `CreateOrder` for selling a mod, including specifying the mod rank. ```rust let order = CreateOrder::sell("serration", 50, 1) .with_mod_rank(10); ``` -------------------------------- ### Get Mod Details (Max Rank) Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/items.md Retrieves a specific item by its slug and checks if it's a mod. If so, it extracts the `ModView` to access its maximum rank. ```rust let mod_item = client.get_item_by_slug("serration").await?; if let Some(mod_view) = mod_item.as_mod() { println!("Max rank: {}", mod_view.max_rank()); } // Create mod order with rank let order = CreateOrder::sell("serration", 50, 1) .with_mod_rank(10); // Max rank ``` -------------------------------- ### Configure Client with Language Selection Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/README.md Builds a client instance configured to use a specific language, such as German. ```rust use wf_market::{Client, Language}; let client = Client::builder() .language(Language::German) .build() .await?; ``` -------------------------------- ### ClientBuilder::build_with_items Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Builds a client instance with pre-loaded items. This is a synchronous operation. ```APIDOC ## ClientBuilder::build_with_items ### Description Builds the client with pre-loaded items (synchronous). ### Method `build_with_items` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **items** (`Vec`) - Required - Pre-loaded items from another source ### Returns `Result>` - The built client or an error. ### Errors - `Error::Network` - If the HTTP client cannot be created ### Example ```rust let items: Vec = load_items_from_file()?; let client = Client::builder().build_with_items(items)?; ``` ``` -------------------------------- ### get_recent_orders Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/orders.md Get recent orders from the last 4 hours. Sorted by creation time (newest first). Results are cached server-side with 1-minute refresh. ```APIDOC ## get_recent_orders() ### Description Get recent orders from the last 4 hours. Sorted by creation time (newest first). Results are cached server-side with 1-minute refresh. ### Method GET (implied) ### Endpoint /recent_orders (inferred) ``` -------------------------------- ### Building Client with Cache Source: https://github.com/kibbewater/wf-market/blob/main/README.md Demonstrates using `build_with_cache()` to avoid re-fetching items for applications that restart frequently. The cache is serializable for persistence. ```rust use wf_market::ApiCache; let mut cache = ApiCache::new(); let client = Client::builder().build_with_cache(&mut cache).await?; let json = serde_json::to_string(&cache.to_serializable())?; ``` -------------------------------- ### Create Client with Specific Language Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Demonstrates creating an HTTP client configured to receive item translations in a specific language, such as German. ```rust // Create a client with German localization let client = Client::builder() .language(Language::German) .build() .await?; // Item names will be in German if let Some(item) = client.get_item_by_slug("serration").await? { println!("Item: {}", item.name()); // May be "Serration" or German name if translated } ``` -------------------------------- ### Get Item by Slug Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Retrieves an item using its URL-friendly slug. Returns `None` if the item is not found. Useful for fetching items via web requests. ```rust if let Some(item) = client.get_item_by_slug("serration") { println!("Max rank: {}", item.as_mod().unwrap().max_rank()); } ``` -------------------------------- ### get_top_orders Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/orders.md Get top orders for an item (best buy and sell prices). Only includes orders from online users. Returns both buy and sell orders separated. ```APIDOC ## get_top_orders(slug: &str, filters: Option<&TopOrderFilters>) ### Description Get top orders for an item (best buy and sell prices). Only includes orders from online users. Returns both buy and sell orders separated. ### Method GET (implied) ### Endpoint /items/{slug}/top_orders (inferred) ### Parameters #### Path Parameters - **slug** (string) - Required - The item's slug #### Query Parameters - **filters** (TopOrderFilters) - Optional - Optional filters for mod rank, charges, stars, or subtype ``` -------------------------------- ### Configure Client with ClientConfig Struct Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/configuration.md Builds an HTTP client by passing a pre-defined ClientConfig struct to the ClientBuilder. ```rust let config = ClientConfig { platform: Platform::Ps4, language: Language::German, crossplay: false, rate_limit: 2, }; let client = Client::builder() .config(config) .build() .await?; ``` -------------------------------- ### Set Client Configuration Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Configure the entire client at once using a `ClientConfig` struct. This method returns `Self` for chaining. ```rust pub fn config(mut self, config: ClientConfig) -> Self ``` ```rust let config = ClientConfig { platform: Platform::Pc, language: Language::English, crossplay: true, rate_limit: 3, }; Client::builder().config(config) ``` -------------------------------- ### Get User Public Profile Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/users.md Retrieves a user's public profile information, including reputation and mastery level. Use this to display basic user details. ```rust pub async fn get_profile(&self, user_slug: &str) -> Result ``` ```rust let profile = client.get_profile("some_user_slug").await?; println!("User: {}", profile.ingame_name); println!("Reputation: {}", profile.reputation); println!("Mastery Level: {:?}", profile.mastery_level); println!("Status: {}", profile.status); if let Some(about) = &profile.about { println!("About: {}", about); } if let Some(background) = &profile.background { println!("Profile background: {}", background); } println!("Featured achievements: {}", profile.achievement_showcase.len()); for achievement in &profile.achievement_showcase { println!(" - {} ({})", achievement.id, achievement.achievement_type); } ``` -------------------------------- ### Client::login Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/client.md Logs in an existing client instance using provided credentials to obtain an authenticated client. This is an asynchronous operation. ```APIDOC ## Client::login ### Description Login with credentials to get an authenticated client. ### Method `login` ### Endpoint N/A (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **credentials** (`Credentials`) - Required - Login credentials (password or token-based) ### Returns `Result>` - The authenticated client or an error. ### Errors - `Error::Auth` - If login fails - `Error::Network` - If the connection fails ### Example ```rust let client = Client::builder().build().await?; let creds = Credentials::new("user@example.com", "password", Credentials::generate_device_id()); let authenticated = client.login(creds).await?; ``` ``` -------------------------------- ### Get Item Statistics Source: https://github.com/kibbewater/wf-market/blob/main/README.md Retrieves historical price and volume statistics for a given item. This snippet shows how to access recent average prices and analyze 90-day trends. ```rust use wf_market::Client; let client = Client::builder().build().await?; let stats = client.get_item_statistics("nikana_prime_set").await?; // Get recent average price from closed trades if let Some(price) = stats.recent_avg_price() { println!("Recent average: {:.0}p", price); } // Analyze 48-hour trend (hourly data) for entry in &stats.statistics_closed.hours_48 { if entry.volume > 0 { println!("{}: {:.0}p avg ({} trades)", entry.datetime.format("%H:%M"), entry.avg_price, entry.volume ); } } // Check 90-day statistics let total_volume = stats.statistics_closed.total_volume_90d(); let has_data = stats.has_sufficient_data(); println!("90-day volume: {} (sufficient data: {})", total_volume, has_data); ``` -------------------------------- ### Get Recent Orders Source: https://github.com/kibbewater/wf-market/blob/main/_autodocs/api-reference/orders.md Retrieves up to 500 of the most recent orders created in the last 4 hours. Results are sorted by creation time and cached server-side with a 1-minute refresh. ```rust pub async fn get_recent_orders(&self) -> Result> ``` ```rust let recent = client.get_recent_orders().await?; for order in &recent { println!( "{} wants to {} {} for {}p", order.user.ingame_name, order.order.order_type, order.order.item_id, order.order.platinum ); } ```