An unofficial client for the SendCloud API. More info about SendCloud on http://sendcloud.nl. Below are some examples on the usage of this client.
Full docs of the SendCloud API can be found on https://api.sendcloud.dev/docs/sendcloud-public-api/getting-started
This project can easily be installed through NuGet.
Install-Package SendCloudApi
Prepare the client for connecting to SendCloud with your API key, API secret and Sendcloud Partner id (optional)
var client = new SendCloudApi.Net.SendCloudApi("apikey", "apisecret", "partnerid")
Returns an array of Parcel objects
var parcels = await client.Parcels.Get();
Returns a Parcel object
var parcel = await client.Parcels.Get(2342);
var parcel = new CreateParcel
{
Name = "John Smith",
CompanyName = "ACME",
Address = "Wellingtonstreet 25",
City = "Wellington",
PostalCode = "3423 DD",
Country = "NL",
RequestLabel = true,
ShippingMethod = 1, // Shipping method, get possibilities from client.ShippingMethods.Get()
OrderNumber = "ORDER2014-52321",
};
var response = await client.Parcels.Create(parcel);
var url = "https://panel.sendcloud.sc/api/v2/labels/normal_printer/{id}";
var label = await client.Label.Download(url);
File.WriteAllBytes("{path}", label);
Actions to the API may cause an Exception to be thrown in case something went wrong
try
{
var response = await client.Parcels.Create(parcel);
}
catch (SendCloudException e)
{
throw new Exception(e.Message);
}