Clone wiki

myob-api / Home



This API provides a java interface to interact with the MYOB API.

Main characteristics

  • Supports desktop and cloud versions of MYOB
  • All entity classes have been translated to java from the 'Contracts' package of the .NET c# SDK provided by MYOB.
  • Two transport classes have been implemented, one using the Apache Http Client library, the other one using plain Java SE (HttpUrlConnection).
  • Google Gson is used for java to json serialization.
  • API supports CDI 1.2 and uses Weld-SE in SE environments.
  • Apache 2 Licensed

Support by donation at

Loving developers:


The artifacts are deployed to Anahata's maven repository

            <name>Anahata Public Repo</name>


Java SE Quickstart

OAuth Log in from a standalone desktop javafx application to get access and refresh tokens and list all company files of the logged in user

JavaFXOAuthAuthenticatorApp.loginAndGetToken(new MyobPlugin("qumsp9e1b8ynw9zhbsbt53dx", "Sj3kswJqB521WmbnqG5XuBWk", "http://localhost"));                
OAuthAccessToken token = JavaFXOAuthAuthenticatorApp.ret;

Retrieve all suppliers of a cloud data file. If the API detects that a token refresh is needed, allow storing the new access and refresh token

        SupplierService cfs = new SupplierService();
        cfs.setEndPointProvider(new MyobEndPointProvider() {
            public MyobEndPoint getEndPoint() {
                OAuthAccessToken token = //read token from database;
                return new MyobEndPoint(MyobEndPoint.CLOUD_ENDPOINT + "b2c48941-7bfb-4f7c-9356-309127f15221", new DataFileCredentials(), token);

            public void oauthTokenRefreshed(MyobEndPoint locator) {
                //store access and refresh token here
        return cfs.findAll();

CDI provided Endpoints

The API can work with CDI (in both SE and EE environments) to provide data file url and credentials without having to configure each an MYOB service instances.

CDI based EndPoint provider supplying EndPoint (Data file locator + OAuth credentials + data file credentials). Use case of one data file and one logon for the entire application. You can Use @RequestScoped rather than @singleton in a multi datafile, multi user scenario.

 * Singleton EJB to store supply myob endpoint details and store access and refresh token whenever it gets refreshed. 
 * @author pablo
public class MyobEndPointProviderServiceImpl implements MyobEndPointProviderService {
    private EntityManager em;

    private DomainConfigServiceImpl dcs;

    private MyobEndPoint endPoint;

    public MyobEndPoint getEndPoint() {
        if (endPoint != null) {
            log.debug("Returning existing singleton endPoint instance {}", endPoint);
            return endPoint;

        DomainConfig dc = dcs.getDomainConfigLocal();

        endPoint = new MyobEndPoint(dc.getMyobEndPointUrl());


        if (dc.getMyobKey() != null) {
            MyobPlugin mp = new MyobPlugin(dc.getMyobKey(), dc.getMyobSecret(), dc.getMyobRedirectUrl());            
            OAuthAccessToken oaat = new OAuthAccessToken(mp, dc.getMyobAccessToken(), dc.getMyobRefreshToken(), dc.getMyobAccessTokenDate(), dc.getMyobAccessTokenExpiresIn());            

        log.debug("Returning newly created singleton endPoint instance {}", endPoint);

        return endPoint;

    //if the token is refreshed, we want to make sure the storage operation succeeds regardless of the transactional context
    public void oauthTokenRefreshed(MyobEndPoint endPoint) {
        log.debug("OauthTokenRefreshed, storing on DB");
        DomainConfig dc = dcs.getDomainConfigLocal();
        log.debug("Updating singleton endpoint instance");
        //update singleton instance


Then on a EJB or any other CDI enabled object

 * Performs persistence operations on customer such as search.
 * @author pablo
public class SomeApplicationService {
    /** Myob Customer Service with CDI configured endpoint and credentials **/
    private CustomerService myobCustomerService;


Adding additional services or convenience methods to the API

While all MYOB entity classes exist in the API, only the services we have needed have been implemented. Implementing a service which has not yet been written is as simple as implementing a simple Service class and its corresponding Page object. Feel free to create new services and add a pull request.


 *  Account Service
 * @author pablo
public class AccountService extends AbstractEntityMyobService<AccountPage, Account> {

    public AccountService() {
        super("GeneralLedger/Account", AccountPage.class, Account.class);

   //Your handy methods

    public Account findByDisplayID(String displayID) {
        List<Account> accounts = super.findAll();
        for (Account account : accounts) {
            if (Objects.equal(account.getDisplayID(), displayID)) {
                return account;
        return null;


And then

public class AccountPage extends EntityPage<Account>{
    public List<Account> Items;