All integrations
Rust + ParseAPI

Rust. Make your first call.

Install the official Rust client and bring ParseAPI into your code.

Official Rust SDK

Rust install
cargo add parseapi
cargo add tokio --features macros,rt-multi-thread

Your language. The same ParseAPI.

Get connected

One country. Your first request.

Look up the United States and print its name.

01

Install the library.

Run the install commands inside a Cargo project.

Terminal
cargo add parseapi
cargo add tokio --features macros,rt-multi-thread
02

Add your secret key.

Create a secret key in Keys. Set it in the terminal that will run the example. Keep it on your server.

Terminal environment
export PARSEAPI_KEY='YOUR_API_KEY'
03

Make a request.

Save this as src/main.rs, then run it. This lookup uses your plan's request allowance.

src/main.rs
#[tokio::main]
async fn main() -> Result<(), parseapi::Error> {
    let parse = parseapi::Client::from_env()?;
    let country = parse.country("US").await?;
    println!("{}", country.name);
    Ok(())
}
Run
cargo run
Expected outputUnited States
Handle API errors

Read the error code and request ID when an API request fails. Branch on the code, such as not_found, rather than the message. A response with valid: false is a successful lookup. Transport failures still propagate.

src/main.rs with error handling
#[tokio::main]
async fn main() -> Result<(), parseapi::Error> {
    let parse = parseapi::Client::from_env()?;
    match parse.country("US").await {
        Ok(country) => println!("{}", country.name),
        Err(error) => {
            if let Some(code) = error.code() {
                eprintln!("API error: {}", code);
            }
            return Err(error);
        }
    }
    Ok(())
}
Requests and retries

SDK methods follow the API routes. Unknown response values stay unknown, rather than becoming empty strings or guesses.

Ordinary lookups retry temporary failures. Separately metered checks make one attempt by default. You can configure the retry count. See the retry policy.

Build with a working example