The Bosta NodeJs SDK provides convenient access to the Bosta API from applications written in the JavaScript language.
npm install --save bostaconst Bosta = require('bosta');
const bosta = new Bosta(
process.env.API_KEY,
process.env.BASE_URL
);API_KEY is your integartion api key with bosta, to get an api key you must be registered, here is the registration link Bosta. And BASE_URL is the url to bosta Apis wheither it's staging or production. If BASE_URL is not sent in initialization as parameter it's production by default.
const deliveryStates = bosta.deliveryStates;const deliveryTypes = bosta.deliveryTypes;const pickupStates = bosta.pickupStates;const pickupTimeSlots = bosta.pickupTimeSlots;const createdDelivery = await bosta.delivery.createDelivery(
type,
specs,
cod,
dropOffAddress,
businessReference,
receiver,
notes,
);
const deliveryId = createdDelivery._id;
const trackingNumber = createdDelivery.trackingNumber;const updatedDeliver = await bosta.deliver.updateDelivery(
deliveryId,
updatePayload
);const deliveries = await bosta.delivery.getAllDeliveries();const delivery = await bosta.delivery.getDeliveryByTrakingNumber(trackingNumber);const trackingHistory = await bosta.delivery.trackDelivery(trackingNumber);const airwayBill = await bosta.delivery.printDeliveryAWB(deliveryId);await bosta.delivery.terminateDelivery(deliveryId);const pickupLocations = await bosta.pickup.getBusinessPickupLocations();
const businessLocationId = pickupLocations[0]._id;const createdPickup = await bosta.pickup.createPickup(
businessLocationId,
scheduledDate,
scheduledTimeSlot,
contactPerson
);
pickupId = createdPickup.message._id;const updatedPickup = await bosta.pickup.updatePickup(
pickupId,
updatePayload
);const pickupRequests = await bosta.pickup.getAllPickups();const pikcupRequest = await bosta.pickup.getPickupById(pickupId);await bosta.pickup.deletePickup(pickupId);const cities = await bosta.city.getAllCities();
const cityId = cities.find(city => city.name === 'Gharbia')._id;const zones = await bosta.zone.getCityZones(cityId);We are open to, and grateful for, any contributions made by the community. By contributing to Bosta, you agree to abide by the code of conduct.
The MIT License (MIT) License.