Skip to content

ac000/libmtdac

Repository files navigation

libmtdac

Builds FreeBSD Build Status CodeQL

  1. Overview
  2. API
  3. Build it
  4. Register with HMRC
  5. How to use
  6. Fraud Prevention Headers
  7. Thread safety
  8. License
  9. Contributing

Overview

An interface to the UK’s HMRC Make Tax Digital API

It currently supports the following MTD APIs

API Version
Business Details 2.0
Business Income Source Summary 3.0
Business Source Adjustable Summary 7.0
CIS Deductions 3.0
Individual Calculations 8.0
Individuals Charges 3.0
Individuals Disclosures 2.0
Individuals Dividends Income 2.0
Individuals Employments Income 2.0
Individuals Expenses 3.0
Individuals Foreign Income 2.0
Individuals Insurance Policies Income 2.0
Individual Losses 6.0
Individuals Other Income 2.0
Individuals Pensions Income 2.0
Individuals Savings Income 2.0
Individuals State Benefits 2.0
Obligations 3.0
Other Deductions 2.0
Property Business 6.0
Self Assessment Accounts 4.0
Self Assessment Assist 1.0
Self Assessment Individual Details 2.0
Self Employment Business 5.0
 
VAT 1.0
 
Create Test User 1.0
Self Assessment Test Support 1.0
Test Fraud Prevention Headers 1.0

API

There are some docs here and in man page format.

Build it

libmtdac is primarily developed under Linux but it also builds and runs under FreeBSD.

NOTE: This requires jansson 2.14.1 or later with DTOA support (the default) for the proper handling of real numbers.

Linux

libmtdac only has a couple of direct dependencies, libcurl & jansson

On Red Hat/Fedora/etc you will need the

libcurl{,-devel}
jansson{,-devel}

packages.

On Debian (something like…)

libcurl4{,-openssl-dev}
libjansson{4,-dev}

The simplest way is to build the rpm (on Red Hat/Fedora) by simply doing

$ make rpm

in the repository root. It just needs a suitable rpmbuild/ directory structure which can be created with

$ mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

and the rpmbuild tool which can be found in the rpm-build package.

FreeBSD

As as well as curl and jansson libraries it also requires libuuid and gmake to build

$ sudo pkg install gmake jansson curl e2fsprogs-libuuid

then build with

$ gmake

or if you don’t have GCC installed

$ gmake CC=clang

Register with HMRC

Before you can actually make use of this, you will need to register the application with the HMRC developer hub. You can register an account here.

Once you’ve registered you can then regsiter your application by the following steps

  1. Goto https://developer.service.hmrc.gov.uk/developer/applications

    Click on “Add an application to the sandbox” on the left hand side.

  2. Select required endpoints (can be changed later)

    No harm in at least selecting all the ones marked MTD

  3. Generate and take note of the ‘client_id’ & ‘client_secret’

  4. Click on “View your application details”

  5. Click on “Redirect URIs”

  6. Click on “Add a redirect URI”

  7. Paste in (minus the quotes) “urn:ietf:wg:oauth:2.0:oob”

How to use

#include <libmtdac/mtd.h>

Link with -lmtdac.

Examples

For real world examples of usage see

Fraud Prevention Headers

HMRC describe various headers that must be added for Fraud Prevention

Some of the information sent in the headers contains somewhat potentially sensitive information, such as OS username, local IP addresses/mac addresses and a unique device id.

Caveat Emptor.

What is sent for each header can be overridden. See the Fraud Prevention Headers section of libmtdac_mtd_h.3.rst for more details.

Thread safety

libmtdac aims to be thread safe.

License

This library is licensed under the GNU Lesser General Public License (LGPL) version 2.1

See COPYING in the repository root for details.

Contributing

See CodingStyle.rst & Contributing.rst

Andrew Clayton <ac@sigsegv.uk>

About

A C library providing an interface to the UK's HMRC Make Tax Digital API

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •