libmtdac
|Builds| |FreeBSD Build Status| |CodeQL|
Overview <#overview>__API <#api>__Build it <#build-it>__Register with HMRC <#register-with-hmrc>__How to use <#how-to-use>__Fraud Prevention Headers <#fraud-prevention-headers>__Thread safety <#thread-safety>__License <#license>__Contributing <#contributing>__
Overview
An interface to the UK’s HMRC Make Tax Digital <https://developer.service.hmrc.gov.uk/api-documentation>__ 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 Capital Gains Income_ 2.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 Reliefs_ 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
================================================== =======
.. _Business Details: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/business-details-api/2.0/oas/page
.. _Business Income Source Summary: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/self-assessment-biss-api/3.0/oas/page
.. _Business Source Adjustable Summary: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/self-assessment-bsas-api/7.0/oas/page
.. _CIS Deductions: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/cis-deductions-api/3.0/oas/page
.. _Individual Calculations: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individual-calculations-api/8.0/oas/page
.. _Individuals Capital Gains Income: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individuals-capital-gains-income-api/2.0/oas/page
.. _Individuals Charges: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individuals-charges-api/3.0/oas/page
.. _Individuals Disclosures: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individuals-disclosures-api/2.0/oas/page
.. _Individuals Dividends Income: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individuals-dividends-income-api/2.0/oas/page
.. _Individuals Employments Income: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individuals-employments-income-api/2.0/oas/page
.. _Individuals Expenses: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individuals-expenses-api/3.0/oas/page
.. _Individuals Foreign Income: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individuals-foreign-income-api/2.0/oas/page
.. _Individuals Insurance Policies Income: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individuals-insurance-policies-income-api/2.0/oas/page
.. _Individual Losses: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individual-losses-api/6.0/oas/page
.. _Individuals Other Income: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individuals-other-income-api/2.0/oas/page
.. _Individuals Pensions Income: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individuals-pensions-income-api/2.0/oas/page
.. _Individuals Reliefs: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individuals-reliefs-api/2.0/oas/page
.. _Individuals Savings Income: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individuals-savings-income-api/2.0/oas/page
.. _Individuals State Benefits: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/individuals-state-benefits-api/2.0/oas/page
.. _Obligations: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/obligations-api/3.0/oas/page
.. _Other Deductions: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/other-deductions-api/2.0/oas/page
.. _Property Business: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/property-business-api/6.0/oas/page
.. _Self Assessment Accounts: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/self-assessment-accounts-api/4.0/oas/page
.. _Self Assessment Assist: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/self-assessment-assist/1.0/oas/page
.. _Self Assessment Individual Details: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/self-assessment-individual-details-api/2.0/oas/page
.. _Self Employment Business: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/self-employment-business-api/5.0/oas/page
.. _VAT: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/vat-api/1.0/oas/page
.. _Create Test User: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/api-platform-test-user/1.0/oas/page
.. _Self Assessment Test Support: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/mtd-sa-test-support-api/1.0/oas/page
.. _Test Fraud Prevention Headers: https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/txm-fph-validator-api/1.0/oas/page
API
There are some docs
here <https://github.com/ac000/libmtdac/tree/master/docs/>__ and in
man page
format <https://github.com/ac000/libmtdac/tree/master/docs/man/>__.
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 <https://developer.service.hmrc.gov.uk/developer/registration>__.
Once you’ve registered you can then regsiter your application by the
following steps
-
Goto https://developer.service.hmrc.gov.uk/developer/applications
Click on “Add an application to the sandbox” on the left hand side.
-
Select required endpoints (can be changed later)
No harm in at least selecting all the ones marked MTD
-
Generate and take note of the ‘client_id’ & ‘client_secret’
-
Click on “View your application details”
-
Click on “Redirect URIs”
-
Click on “Add a redirect URI”
-
Paste in (minus the quotes) “urn:ietf:wg:oauth:2.0:oob”
How to use
.. code:: c
#include <libmtdac/mtd.h>
Link with -lmtdac.
Examples
For real world examples of usage see
- `mtd-cli <https://github.com/ac000/mtd-cli>`__
- `itsa <https://github.com/ac000/itsa>`__
Fraud Prevention Headers
------------------------
HMRC describe various headers that must be added for `Fraud
Prevention <https://developer.service.hmrc.gov.uk/api-documentation/docs/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 </docs/libmtdac_mtd.h.3.rst#fraud-prevention-headers>`__ section
of `libmtdac_mtd_h.3.rst </docs/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 </COPYING>`__ in the repository root for details.
Contributing
------------
See `CodingStyle.rst </CodingStyle.rst>`__ &
`Contributing.rst </Contributing.rst>`__
Andrew Clayton <ac@sigsegv.uk>
.. |Builds| image:: https://github.com/ac000/libmtdac/actions/workflows/build_tests.yaml/badge.svg
:target: https://github.com/ac000/libmtdac/actions/workflows/build_tests.yaml
.. |FreeBSD Build Status| image:: https://api.cirrus-ci.com/github/ac000/libmtdac.svg
:target: https://cirrus-ci.com/github/ac000/libmtdac
.. |CodeQL| image:: https://github.com/ac000/libmtdac/workflows/CodeQL/badge.svg
:target: https://github.com/ac000/libmtdac/actions?query=workflow:CodeQL