Unofficial wrapper of the p:e accounting API for .NET. Built in C# targeting .NET Standard 2.0. Based on the public documentation.
- 📈 Typed wrappers for the PE Accounting API
- 🐧 Cross platform: Targets .NET Standard 2.0 (Use from .NET Framework and .NET Core)
The API-wrapper supports all these methods:
- Company
GetCompanyInfoAsync()
- User
GetMyUserAsync()
GetUsersAsync()
GetUserAsync(int userId)
- Clients
GetClientsAsync()
- Projects
GetProjectsAsync()
- Client projects
GetClientProjectsAsync()
GetClientProjectsAsync(ClientProjectFilter filter)
GetClientProjectAsync(int clientProjectId)
- Expenses
GetExpensesAsync()
GetExpensesAsync(ExpenseFilter filter)
- Activities
GetActivitiesAsync()
GetActivityAsync(int activityId)
- Events
GetEventsAsync()
GetEventsAsync(EventFilter filter)
GetEventAsync(int eventId)
CreateEventAsync(EventCreate item)
DeleteEventAsync(int eventId)
- Client invoices
GetClientInvoicesAsync()
GetClientInvoicesAsync(ClientInvoiceFilter filter)
CreateClientInvoiceAsync(ClientInvoiceCreate item)
CreateClientInvoiceAsync(ClientInvoiceCreate item, ClientInvoiceCreateOptions options)
- Client invoice templates
GetClientInvoiceTempatesAsync()
- Client delivery types
GetClientDeliveryTypesAsync()
- Dimensions
GetDimensionsAsync()
GetDimensionEntriesAsync(int dimensionId)
- Products
GetProductsAsync()
GetProductAsync(int productId)
- General ledger accounts
GetGeneralLedgerAccountsAsync(DateTime startDate, DateTime endDate)
Please start by reading the official documentation to get a basic understanding of the API: https://my.accounting.pe/api/v1/doc
Orneholm.PEAccountingNet is distributed as packages on NuGet, install using the tool of your choice, for example dotnet cli.
dotnet add package Orneholm.PEAccountingNet
The main API is scoped to a single company and restricted to the access rights of a single user given a personal access token.
The PeaAuthenticationApi
provides a simple way of retrieving those companies and tokens given a username and password.
Example:
var authenticationApi = PeaAuthenticationApi.CreateClient();
var companies = await authenticationApi.GetAccessibleCompaniesAsync("username", "password");
foreach (var company in companies)
{
Console.WriteLine($"{company.Name} ({company.Id}): {company.Token}");
}
Example:
var api = PeaApi.CreateClient(company.Id, company.Token);
// List clients
var clients = await api.GetClientsAsync();
foreach (var client in clients)
{
Console.WriteLine($"{client.Name} ({client.Id}): {client.OrgNr}");
}
// List client projects
var clientProjects = await api.GetClientProjectsAsync();
foreach (var clientProject in clientProjects)
{
Console.WriteLine($"{clientProject.Name} ({clientProject.Id}): {clientProject.Comment}");
}
// Create event
await api.CreateEventAsync(new EventCreate()
{
Date = DateTime.Today.Date,
Hours = 1,
UserId = 12345,
ActivityId = 67890,
ClientProjectId = 13579,
Comment = "Doing work",
InternalComment = "Work"
});
The native models used to map the XML requests and responses are not exposed through the API, but instead beeing mapped against custom models. This enabled the API to follow the conventions of C# but also makes sure that any breaking change in the models is beeing noticed.
The models are auto generated using xsd.exe with the XSD source from p:e accoutning.
To generate new classes, download a new version of the XSD, place it in /Models/Native and run the following command from Developer Command Prompt for Visual Studio.
xsd NativeModels.xsd /c /n:Orneholm.PEAccountingNet.Models.Native
For more use cases, samples and inspiration; feel free to browse our sample.
We are very open to community contributions. Please see our contribution guidelines before getting started.
Orneholm.PEAccountingNet is licensed under the very permissive MIT license for you to be able to use it in commercial or non-commercial applications without many restrictions.
The brand PE Accounting belongs to PE Accounting.