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_USERNAME!, password: process.env.BIGSHIP_PASSWORD!, accessKey: process.env.BIGSHIP_ACCESS_KEY!,});
// Check profile + wallet balanceconst profile = await client.getProfile();if (isSuccessResponse(profile)) { console.log('Wallet balance:', profile.data?.userWallet?.Balance);}What Happens Internally
Section titled “What Happens Internally”When you call getProfile():
- Authenticate — SDK checks for a cached token; if missing/expired, calls login endpoint
- Make request — Sends
GET /api/outbound/profilewith auth header - Validate response — Parses and validates the response with Zod
- Dispatch hooks — Fires
onResponseoronErrorhooks - Return — Returns typed
ApiResponse<ProfileData>
Response Shape
Section titled “Response Shape”All methods return ApiResponse<T>:
interface ApiResponse<T> { status: boolean; message: string; status_code: number; data: T | null;}Use type guards to safely access data:
import { isSuccessResponse, isFailedResponse } from '@agamya/bigship-sdk';
const result = await client.getProfile();
if (isSuccessResponse(result)) { console.log(result.data); // Typed as ProfileData} 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