First Request
Quick Start
Section titled “Quick Start”import { BigshipClient, isSuccessResponse } from '@agamya/bigship-sdk';
const client = new BigshipClient({ baseURL: process.env.BIGSHIP_BASE_URL!, userName: process.env.BIGSHIP_USER_NAME!, password: process.env.BIGSHIP_PASSWORD!, accessKey: process.env.BIGSHIP_ACCESS_KEY!,});
// Check wallet balanceconst balance = await client.getWalletBalance();if (isSuccessResponse(balance)) { console.log('Balance:', balance.data); // → "5000.00"}What Happens Internally
Section titled “What Happens Internally”When you call getWalletBalance():
- Authenticate — SDK checks for a cached token; if missing/expired, calls login endpoint
- Make request — Sends
GET /api/Wallet/balance/getwith auth header - Validate response — Parses and validates the response with Zod
- Dispatch hooks — Fires
onResponseoronErrorhooks - Return — Returns typed
ApiResponse<{ balance: string }>
Response Shape
Section titled “Response Shape”All methods return ApiResponse<T>:
interface ApiResponse<T> { status: 'success' | 'error'; data: T | null; message?: string;}Use type guards to safely access data:
import { isSuccessResponse, isFailedResponse } from '@agamya/bigship-sdk';
const result = await client.getCourierList('b2c');
if (isSuccessResponse(result)) { console.log(result.data); // Typed as Courier[]} else if (isFailedResponse(result)) { console.error(result.message);}Next Steps
Section titled “Next Steps”- B2C Shipment Guide — Complete B2C lifecycle
- B2B Shipment Guide — B2B with e-waybill
- Error Handling — Structured error handling
- Configuration — All config options