Code Examples
These examples use the current API-key SDK surface. Wallet-authenticated app routes use the JWT flow described in the authentication guide.
curl
bash · curl
curl -X POST https://api.sw4p.io/sdk/v1/estimate \
-H "Content-Type: application/json" \
-H "X-API-Key: sk_555_live_your_api_key" \
-d '{
"from": "BASE",
"to": "SOLANA",
"amount": "25.00",
"speed": "fast"
}'
TypeScript
typescript
import { Sw4pClient } from "@sw4p/sdk";
const client = new Sw4pClient({
apiKey: process.env.SW4P_API_KEY!,
});
const estimate = await client.estimate({
from: "BASE",
to: "SOLANA",
amount: "25.00",
speed: "fast",
});
console.log(estimate.fee.total);
Rust
rust
use sw4p_sdk::{Chain, EstimateParams, Sw4pClient, TransferSpeed};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Sw4pClient::new(std::env::var("SW4P_API_KEY")?);
let estimate = client
.estimate(&EstimateParams {
from: Chain::Base,
to: Chain::Solana,
amount: "25.00".to_string(),
speed: Some(TransferSpeed::Fast),
})
.await?;
println!("{}", estimate.fee.total);
Ok(())
}
Python
python
import os
import requests
response = requests.post(
"https://api.sw4p.io/sdk/v1/estimate",
headers={
"Content-Type": "application/json",
"X-API-Key": os.environ["SW4P_API_KEY"],
},
json={
"from": "BASE",
"to": "SOLANA",
"amount": "25.00",
"speed": "fast",
},
timeout=30,
)
response.raise_for_status()
print(response.json()["fee"]["total"])
Status Polling
bash · curl
curl https://api.sw4p.io/sdk/v1/status/de305d54-75b4-431b-adb2-eb6b9e546014 \
-H "X-API-Key: sk_555_live_your_api_key"