Client library for accessing the EasyPost Shipping API via C#
var easyPost = new EasyPostClient("YOUR_LIVE_API_KEY");
var fromAddress = easyPost.CreateAddress(new Address
{
Name = "EasyPost",
Street1 = "2135 Sacramento St",
City = "San Francisco",
State = "CA",
Zip = "94109",
Email = "[email protected]",
});
var toAddress = easyPost.CreateAddress(new Address
{
Company = "Cool Company Name",
Street1 = "123 Main Street",
City = "New York",
State = "NY",
Zip = "10001",
});
var customParcel = easyPost.CreateParcel(new Parcel
{
LengthInches = 6,
WidthInches = 6,
HeightInches = 4,
WeightOunces = 13,
});
var shipment = new Shipment
{
FromAddress = fromAddress,
ToAddress = toAddress,
Parcel = customParcel,
});
shipment.Options.Add("delivery_confirmation", "SIGNATURE");
shipment = easyPost.CreateShipment(shipment);
var cheapestRate = shipment.Rates.OrderBy(x => x.Rate).First();
var label = easyPost.BuyPostageLabel(shipment.Id, cheapestRate);
Add this to your project using NuGet.