# fsolver An easy to use, asynchronous wrapper for [FlareSolverr](https://github.com/FlareSolverr/FlareSolverr). ## Requirements * **An instance of FlareSolverr running on your machine or a server.** For more information on how to set up FlareSolverr, visit the [official repository](https://github.com/FlareSolverr/FlareSolverr?tab=readme-ov-file#installation). ## Installation ```bash # With default features (only `async`) cargo add fsolver # With all features (`async` and `blocking`) cargo add fsolver -F all # Only blocking cargo add fsolver --no-default-features -F blocking ``` ## Usage For more info, visit the [documentation](https://docs.rs/fsolver/1.0.0/fsolver/). ### Async ```rust use fsolver::FlareSolverrAsync; // Setup the flare solver instance with default settings let solver = FlareSolverrAsync::new(None, None, None, None, None) .await .unwrap(); // With custom ip and port let solver = FlareSolverrAsync::new(Some("127.0.0.1"), Some("5050"), None, None, None) .await .unwrap(); // Use different http schema use fsolver::HttpSchema; let solver = FlareSolverrAsync::new(None, None, Some(HttpSchema::Http), None, None) .await .unwrap(); // If you want some additional headers use std::collections::HashMap; let mut headers = HashMap::new(); headers.insert("User-Agent".to_string(), "Mozilla/5.0 (X11; Linux x86_64)".to_string()); let solver = FlareSolverrAsync::new(None, None, None, Some(headers), None) .await .unwrap(); // When (for whatever the reason) flaresolverr changes /v1 endpoint let solver = FlareSolverrAsync::new(None, None, None, None, Some("v2")) .await .unwrap(); // List all sessions let sessions: Vec = solver.sessions().await.unwrap(); // List sessions and get response raw let sessions: SessionListResponse = solver.sessions().await.unwrap(); // Create a new session with a random UUID let session_id = solver.create_session(None).await.unwrap(); // Create a new session with a custom name/ID let session_id = "myses"; let session_id = solver.create_session(Some(session_id)).await.unwrap(); // Delete/destroy a session solver.destroy_session(session_id).await.unwrap(); // Get request use fsolver::RequestGet; let session_id = solverr.create_session(None).await.unwrap(); let get_request_params = RequestGet::new( "https://example.com".into(), Some(session_id), None, None, None, None, None, ); let response: GetPostRequestResponse = solver.request_get(get_request_params).await.unwrap() // Post request use fsolver::RequestPost; let post_request_params = RequestPost::new_empty("https://example.com".to_string(), "a=b&c=d".to_string()) let response: GetPostRequestResponse = solver.request_post(post_request_params).await.unwrap(); ``` ### Blocking ```rust use fsolver::FlareSolverrBlocking; // Yep, just that. All functions are the same. Call functions without await. ```