Skip to main content

Interface to the FreeAgent accounting software API

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

freeagent_api-0.5.0.tar.gz (91.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

freeagent_api-0.5.0-py3-none-any.whl (41.2 kB view details)

Uploaded Python 3

File details

Details for the file freeagent_api-0.5.0.tar.gz.

File metadata

  • Download URL: freeagent_api-0.5.0.tar.gz
  • Upload date:
  • Size: 91.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for freeagent_api-0.5.0.tar.gz
Algorithm Hash digest
SHA256 720d141c357868f09ff2aa4d736ff94215868f5a6f994ae5ec8fcb71ee286684
MD5 aff9a727d1ec17c003667c9166141a43
BLAKE2b-256 b05b19defd896fdfa16c6bf865bab6b17914e1005bc7db51ee898bd6b0b64697

See more details on using hashes here.

File details

Details for the file freeagent_api-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: freeagent_api-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 41.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for freeagent_api-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 537896fb520cdb3e6f8f7e0b309865a682b1a434a1312419cbf6d75021fcedec
MD5 038b56770a7b4263293be510a1131494
BLAKE2b-256 7f1f393ba960a8527e49944d10248b84fb31eb2c40c26f8fe37f2362e1ae3378

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page