Build
SDK examples
Copy-paste examples for common languages. Official SDKs are planned; these use plain HTTP clients.
Create an order
curl -X POST https://sandbox.api.nesvra.com/api/v1/orders \
-H "Authorization: Bearer $NESVRA_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"items":[{"product":"japan-10gb-30d","quantity":1}],"customer":{"email":"traveller@example.com"}}'
Create an order (PHP, Guzzle)
$client = new GuzzleHttp\Client(['base_uri' => 'https://sandbox.api.nesvra.com/api/v1/']);
$res = $client->post('orders', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('NESVRA_KEY'),
'Idempotency-Key' => bin2hex(random_bytes(16)),
],
'json' => ['items' => [['product' => 'japan-10gb-30d', 'quantity' => 1]], 'customer' => ['email' => 'traveller@example.com']],
]);
$order = json_decode((string) $res->getBody(), true)['data'];
Create an order (Node.js 18+)
const res = await fetch('https://sandbox.api.nesvra.com/api/v1/orders', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.NESVRA_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({ items: [{ product: 'japan-10gb-30d', quantity: 1 }], customer: { email: 'traveller@example.com' } }),
});
const { data: order } = await res.json();
Create an order (Python, requests)
import os, uuid, requests
res = requests.post(
'https://sandbox.api.nesvra.com/api/v1/orders',
headers={'Authorization': f"Bearer {os.environ['NESVRA_KEY']}", 'Idempotency-Key': str(uuid.uuid4())},
json={'items': [{'product': 'japan-10gb-30d', 'quantity': 1}], 'customer': {'email': 'traveller@example.com'}},
timeout=15,
)
order = res.json()['data']