Skip to content

wolfgang-werner/lexoffice-go-api

Repository files navigation

lexoffice Go API

This module implements a Go REST client for the public API from lexoffice. With the help of the API one can work with entities from the cloud-based accounting software.

lexoffice

Setup

To work with the lexoffice API, you need to setup a lexoffice test instance and get an API key.
Thankfully these steps can be done online (without credit card) in some minutes.

To get the test instance (provided 30 days free of charge by lexoffice), just hit https://www.lexoffice.de and create your test-account. You have to verify your email address and setup your password on first login.

After you have successfully logged in, just go to https://app.lexoffice.de/settings/#/public-api to create your API key, attached to your instance and valid for 24 months.

You can find the vendor explanation for this in the cookbook.

This module needs this API key to connect. You'll provide the API key as an environment variable or in an .env file (you can also hard-code it in your project if you dare).

To export the API key in an environment variable, just define it, e.g.

~ export LEXOFFICE_API_KEY=########-####-####-####-############

Alternatively, To create the .env file, just run:

~ echo "LEXOFFICE_API_KEY=########-####-####-####-############" > .env

You can check the file content with:

~ cat .env
LEXOFFICE_API_KEY=########-####-####-####-############

Of course you can provide the API key in every command, also, eg.:

LEXOFFICE_API_KEY=########-####-####-####-############ go test -v -tags=integration

Install module

go get -u github.com/wolfgang-werner/lexoffice-go-api

Usage

import "github.com/wolfgang-werner/lexoffice-go-api"

// Replace API_KEY with your real key
client := lexoffice.NewClient("API_KEY")

// enable debug output
client.debug = true

Testing

Run integration tests with real API Key.

LEXOFFICE_API_KEY=########-####-####-####-############ go test -v -tags=integration

Links

The following resources have been very helpful in writing this module.