Skip to main content

Crate namecheap_client

Crate namecheap_client 

Source
Expand description

An unofficial, async Rust client for the Namecheap API.

This crate wraps the parts of the Namecheap API needed to check, register, and configure domains, so you do not have to hand-roll HTTP requests and XML parsing. It is not affiliated with or endorsed by Namecheap.

§Supported commands

§Requirements

Every request is authenticated with your API user, API key, and account username, and must originate from an IP address you have whitelisted in the Namecheap API settings. That same address is sent as the ClientIp parameter, so it must match your real outbound public IPv4 address.

§Example

use namecheap_client::{Client, Environment};

#[tokio::main]
async fn main() -> Result<(), namecheap_client::Error> {
    let client = Client::builder()
        .api_user("your-api-user")
        .api_key("your-api-key")
        .client_ip("203.0.113.10") // your whitelisted public IPv4
        .environment(Environment::Sandbox)
        .build()?;

    for result in client.domains().check(["example.com", "rust-lang.org"]).await? {
        println!("{}: available = {}", result.domain, result.available);
    }

    Ok(())
}

§TLS backends

By default the crate uses rustls so it builds without a system OpenSSL installation. To use the platform-native TLS stack instead, disable default features and enable native-tls:

namecheap-client = { version = "0.1", default-features = false, features = ["native-tls"] }

Re-exports§

pub use domains::Contact;
pub use domains::Dns;
pub use domains::DomainCheckResult;
pub use domains::DomainCreateRequest;
pub use domains::DomainCreateResult;
pub use domains::DomainListItem;
pub use domains::DomainListResult;
pub use domains::Domains;
pub use domains::EmailType;
pub use domains::GetHostsResult;
pub use domains::HostInfo;
pub use domains::HostRecord;
pub use domains::RecordType;
pub use domains::SetAutoRenewResult;
pub use domains::SetHostsRequest;
pub use domains::SetHostsResult;
pub use users::Balances;
pub use users::Price;
pub use users::PricingRequest;
pub use users::PricingResult;
pub use users::ProductCategoryPricing;
pub use users::ProductPricing;
pub use users::ProductTypePricing;
pub use users::Users;

Modules§

domains
The namecheap.domains command namespace: availability checks, registration, and DNS host records.
users
The namecheap.users command namespace.

Structs§

ApiError
One or more errors returned by Namecheap inside an XML response.
ApiErrorEntry
A single error reported by Namecheap.
Client
An asynchronous client for the Namecheap API.
ClientBuilder
A builder for Client.

Enums§

Environment
Which Namecheap environment to talk to.
Error
Any error that can occur while talking to the Namecheap API.

Type Aliases§

Result
A convenient alias for results returned by this crate.