Skip to main content

FreeAgent API

A package for interacting with the FreeAgent accounting software.

Mainly made for personal use, but sharing it here because... well, why not? :-)

Limitations

Currently only invoice related functionality is available. Other features are likely to be added in time.

Install from PyPI

pip install freeagent_api

Usage

import freeagent_api

api = freeagent_api.ApiClient(
    client_id = '<client id from dev.freeagent.com>',
    client_secret = '<client secret from dev.freeagent.com>',
    use_sandbox = True,
)

# Load a serialised token from wherever you store them here
api.serialised_token = your_storage.get_token() # Implement this yourself
# or ask the user to authorise access to their account
api.do_auth()

# Get some basic info about the authenticated user
user = api.get_user()
company = api.get_company()
print(f"{user.fullname} works for {company.name}")
print()

# Find unpaid invoices
for invoice in api.get_invoices(status = "open_or_overdue"):
    print(f"Invoice {invoice.reference} for {invoice.currency} {invoice.total_value} is unpaid")

# Store the authentication token for later use
storage.set_token(api.serialised_token) # Implement this yourself

This will, assuming appropriate invoices exist, display something along the lines of:

Tim the Enchanter works for Arthurian Enchanters Ltd

Invoice ART01 for GBP 112.15 is unpaid
Invoice ART02 for USD 245.10 is unpaid
Invoice RBT01 for GBP 2.50 is unpaid

Available data

See FreeAgent's official API documentation for the basic fields in each object. In addition to those, the following properties and methods are available:

freeagent_api.Company

  • address(include_country = True) returns the full address of the authorised user's company as a multiline string.

freeagent_api.Contact

  • address(include_country = True) returns the full address of the contact as a multiline string.
  • fullname returns the first and last name of the contact (if defined) as a single string.
  • name returns the name to use on invoices. This will either be the contact's full name or company name, depending on which is defined and the contact_name_on_invoices setting for the contact.

freeagent_api.User

  • fullname returns the first and last name of the authorised user as a single string.

Acknowledgements

Repository ison is adapted from 'accounting' by Vectors Market from Noun Project (CC BY 3.0), with the currency symbol replaced.

Metadata

Release files for freeagent-api 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for freeagent-api 0.5.0
File Size Uploaded Provenance
freeagent_api-0.5.0.tar.gz 91.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for freeagent-api 0.5.0
File Interpreter ABI Platform
freeagent_api-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 132.5 kB

Release files / freeagent_api-0.5.0.tar.gz

Download URL freeagent_api-0.5.0.tar.gz
Size 91.3 kB
Tags Source
SHA-256 checksum
How to use checksums
720d141c357868f09ff2aa4d736ff94215868f5a6f994ae5ec8fcb71ee286684
BLAKE2b-256 checksum
How to use checksums
b05b19defd896fdfa16c6bf865bab6b17914e1005bc7db51ee898bd6b0b64697
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / freeagent_api-0.5.0-py3-none-any.whl

Download URL freeagent_api-0.5.0-py3-none-any.whl
Size 41.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
537896fb520cdb3e6f8f7e0b309865a682b1a434a1312419cbf6d75021fcedec
BLAKE2b-256 checksum
How to use checksums
7f1f393ba960a8527e49944d10248b84fb31eb2c40c26f8fe37f2362e1ae3378
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Security for freeagent-api 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page