{"id":21189285,"url":"https://github.com/uptick/pymyob","last_synced_at":"2025-04-06T00:09:11.188Z","repository":{"id":44734125,"uuid":"72405337","full_name":"uptick/pymyob","owner":"uptick","description":"A Python SDK for the MYOB Business (formerly AccountRight Live, and New Essentials) API.","archived":false,"fork":false,"pushed_at":"2024-11-25T03:24:20.000Z","size":307,"stargazers_count":19,"open_issues_count":3,"forks_count":24,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-29T23:09:21.659Z","etag":null,"topics":["myob","myob-accountright","myob-business","myob-essentials","python","python-api-wrapper","python-sdk"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uptick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-31T05:41:06.000Z","updated_at":"2024-12-29T05:56:44.000Z","dependencies_parsed_at":"2023-01-25T13:30:59.638Z","dependency_job_id":"1af93cd7-47d4-4ecf-b6ae-8400e0ff6158","html_url":"https://github.com/uptick/pymyob","commit_stats":{"total_commits":195,"total_committers":20,"mean_commits":9.75,"dds":"0.32820512820512826","last_synced_commit":"6173c6174b565723ae5810a554bac3cd92c2b069"},"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptick%2Fpymyob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptick%2Fpymyob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptick%2Fpymyob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptick%2Fpymyob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uptick","download_url":"https://codeload.github.com/uptick/pymyob/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415967,"owners_count":20935387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["myob","myob-accountright","myob-business","myob-essentials","python","python-api-wrapper","python-sdk"],"created_at":"2024-11-20T18:51:28.082Z","updated_at":"2025-04-06T00:09:11.167Z","avatar_url":"https://github.com/uptick.png","language":"Python","readme":"# PyMYOB\n\n[![PyPI version](https://badge.fury.io/py/pymyob.svg)](https://pypi.org/project/pymyob)\n[![versions](https://img.shields.io/pypi/pyversions/pymyob.svg)](https://pypi.org/project/pymyob)\n[![Downloads](https://static.pepy.tech/badge/pymyob/month)](https://pepy.tech/project/pymyob)\n[![Test](https://github.com/uptick/pymyob/workflows/Test/badge.svg)](https://github.com/uptick/pymyob/actions?query=workflow%3ATest)\n[![Lint](https://github.com/uptick/pymyob/workflows/Lint/badge.svg)](https://github.com/uptick/pymyob/actions?query=workflow%3ALint)\n\nA Python API around the [MYOB Business API](https://developer.myob.com/api/myob-business-api/v2/) (formerly AccountRight Live, and New Essentials).\n\n## Pre-getting started\n\nRegister for API Keys with MYOB. You'll find detailed instructions [here](http://developer.myob.com/api/accountright/api-overview/getting-started/).\n\n## Getting started\n\nInstall:\n\n```\npip install pymyob\n```\n\nCreate a `PartnerCredentials` instance and provide the Key, Secret and Redirect Uri as you've set up in MYOB:\n\n```\nfrom myob.credentials import PartnerCredentials\n\ncred = PartnerCredentials(\n    consumer_key=\u003cKey\u003e,\n    consumer_secret=\u003cSecret\u003e,\n    callback_uri=\u003cRedirect Uri\u003e,\n)\n```\n\nCache `cred.state` somewhere. You'll use this to rebuild the `PartnerCredentials` instance later.\nThis object includes a datetime object, so if your cache does not serialise datetime objects, you'll need to find an alternative, such as pickling and saving to a binary database column.\n\nRedirect the user to `cred.url`. There, they will need to log in to MYOB and authorise partnership with your app\u003csup id=\"a1\"\u003e[1](#f1)\u003c/sup\u003e. Once they do, they'll be redirected to the Redirect Uri you supplied.\n\nAt the url they're redirected to, rebuild the `PartnerCredentials` then pick the verifier out of the request and use it to verify the credentials.\n\n```\nfrom myob.credentials import PartnerCredentials\n\ndef myob_authorisation_complete_view(request):\n    verifier = request.GET.get('code', None)\n    if verifier:\n        state = \u003ccached_state_from_earlier\u003e\n        if state:\n            cred = PartnerCredentials(**state)\n            cred.verify(verifier)\n            if cred.verified:\n                messages.success(request, 'OAuth verification successful.')\n            else:\n                messages.error(request, 'OAuth verification failed: verifier invalid.')\n        else:\n            messages.error(request, 'OAuth verification failed: nothing to verify.')\n    else:\n        messages.error(request, 'OAuth verification failed: no verifier received.')\n```\n\nSave `cred.state` once more, but this time you want it in persistent storage. So plonk it somewhere in your database.\n\nWith your application partnered with MYOB, you can now create a `Myob` instance, supplying the verified credentials:\n\n```\nfrom myob import Myob\nfrom myob.credentials import PartnerCredentials\n\ncred = PartnerCredentials(**\u003cpersistently_saved_state_from_verified_credentials\u003e)\nmyob = Myob(cred)\n```\n\nYou're almost there! MYOB has this thing called company files. Even though you've authorised against a user now, you need to collect a further set of credentials for getting into the company file.\n\n```\ncompanyfiles = myob.companyfiles.all()\n\n# Each company file has the following attrs:\ncomp.id  # Company Id\ncomp.name  # Company Name\ncomp.data  # Remaining data as a raw dict.\n```\nTip: the companyfiles object specifies all supported managers (that is, endpoints).\n\nRender a dropdown for your user to let them select which of the company files they wish to use. Usually there will only be one against their account, but best to check.\nIf additional authentication against the company file is needed (ie when the company file account isn't tied via SSO to a my.myob account), prompt them for the username and password for that company file and save this as follows:\n\n```\ncred.authenticate_companyfile(\u003ccompany_id\u003e, \u003cusername\u003e, \u003cpassword\u003e)\n```\n\nSave the new `cred.state` back to your persistent storage.\n\nNow you can access stuff!\n\n```\nfrom myob import Myob\nfrom myob.credentials import PartnerCredentials\n\ncred = PartnerCredentials(**\u003cpersistently_saved_state_from_verified_credentials\u003e)\nmyob = Myob(cred)\n\n# Obtain list of company files. Here you will also find their IDs, which you'll need to retrieve a given company file later.\ncompany_files = myob.companyfiles.all()\n\n# Obtain a specific company file. Use `call=False` to just prep it for calling other endpoints without actually making a call yet at this stage.\ncomp = myob.companyfiles.get(\u003ccompany_id\u003e, call=False)\n\n# Obtain a list of customers (two ways to go about this).\ncustomers = comp.contacts.all(Type='Customer')\ncustomers = comp.contacts.customer()\n\n# Obtain a list of sale invoices (two ways to go about this).\ninvoices = comp.invoices.all(InvoiceType='Item', orderby='Number desc')\ninvoices = comp.invoices.item(orderby='Number desc')\n\n# Create an invoice.\ncomp.invoices.post_item(data=data)\n\n# Obtain a specific invoice.\ninvoice = comp.invoices.get_item(uid=\u003cinvoice_uid\u003e)\n\n# Download PDF for a specific invoice.\ninvoice_pdf = comp.invoices.get_item(uid=\u003cinvoice_uid\u003e, headers={'Accept': 'application/pdf'})\n\n# Obtain a list of tax codes.\ntaxcodes = comp.general_ledger.taxcode()\n\n# Obtain a list of inventory items.\ninventory = comp.inventory.item()\n\n# Use endswith, startswith, or substringof filters\nsearch_text = 'Acme'\ncustomers = comp.contacts.customer(raw_filter=f\"substringof('{search_text}', CompanyName)\")\n```\n\nIf you don't know what you're looking for, the reprs of most objects (eg. `myob`, `comp`, `comp.invoices` above) will yield info on what managers/methods are available.\nEach method corresponds to one API call to MYOB.\n\nNote that not all endpoints are covered here yet; we've just been adding them on an as-needed basis. If there's a particular endpoint you'd like added, please feel free to throw it into the endpoints.py file and open up a PR. All contributions are welcome and will be reviewed promptly. :)\n\n##\n\n\u003ca name=\"f1\"\u003e1\u003c/a\u003e: Your users can review their partner authorisations at https://secure.myob.com/. [↩](#a1)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuptick%2Fpymyob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuptick%2Fpymyob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuptick%2Fpymyob/lists"}