The Manager API

Hello,

I have recently started using the manager API. I want to create a bunch of useful scripts for requesting info, in Python.

@Lubos, this is great! I’m really glad, so many years on, to be so gladly still using manager. It’s grown my business greatly! Hopefully, this API will make life even easier. Could you comment on the status of the API? Do we have anything more than GET at the moment?

I was hoping this would become a useful place to have some ‘centralised’ discussion on the API, as I see many have been created.

@everyone, who would be interested in the scripts I mentioned above? Maybe an Open Source project could be started for this, some basic interaction, and maybe more advanced options? Let me know in anyone is interested…

One note, I see that only admin accounts can access the API, is that the intended path for the API?

Again, great work Lubos!

Andrew

2 Likes

Only GET is supported at the moment but I’ll try to add PUT, POST and DELETE commands in upcoming days.

I think I will create new section in Manager where you will be able to create API keys.

1 Like

Thanks Lubos, I will definitely be writing some scripts to make use of that when it comes out.

I have created a basic script for those that are interested.

Also, if you want to add your own efforts, let me know.

The script will pull from you host, and give you back Json.

It is in python.

Warning! Is it very un-polished, but it’s a good starting point.

EDIT:

Look further down for the link to the script

Hello Lubos, Is there any update on the API: POST, PUT and DELETE? I know you guys are busy with the road map, I just want to have some sort of indication, so I can plan a few things.

The latest version (16.4.56) supports POST, PUT and DELETE.

Also, since I’ve made some significant changes to API, it’s at new URL. Navigate to /api instead of /objects

This is great! I will start investigating and carrying on on that those scripts. Thanks Lubos!!

Hi All, sorry if this is a silly question but would the API allow me to “link” Manager to Paypal to pull in the payment data from a website. If so, are there any existing scripts that would be available to use? Thanks for your help.

Not at the moment, but the API would allow such an integration


@Lubos, do you plan to allow also API acces to the desktop version? I don’t need a multi-user server setup but allowing to interface with the desktop version would allow for some nice tricks…

Desktop edition will have API too. The reason why desktop edition doesn’t support API right now is that it doesn’t have a concept of users since it’s single-user product. And right now, API is relying on users for authentication.

I will be introducing ability to create API keys which will act as API credentials (users won’t be used to API) and this will be extended to desktop edition.

@lubos

The API is currently broken for use with scripts (or my server setup is, but I think it’s manager)
I think it is just a redirection issue.

  • If one is logged into the website, one can then navigate to api with no issue, sign in and continue.
    However, if your not logged in, api just redirects you to api/login.

  • On the same issue, objects still exists, but just gives you a blank page.

  • Also, navigating to <something-else> doesn’t redirect you to login, it redirects you to <something-else>/login.

I think this is just some of the server setup? I’m pretty sure it’s not on the OS side, is it?

@procsum, this didn’t mean to happen. Can you please upgrade to the latest version (16.4.68)

Hey @lubos,

All the problems I mentioned are now fixed. Thanks!

I’m starting to get somewhere. Thank you for including index.json objects on some of the pages. It makes it a lot nicer to find the next object in the string of objects.

Could you add an index page to all the pages? It will then make navigating the API through the script a lot easier.

At the moment the flow is like this.

  1. Get the api index.json
  2. Look for the specified business.
  3. Get the index.json for the key at business (which we can’t do at the moment since there isn’t an index here.)
  4. Look for the group … and so on.

Each time above, the script auths, fetches from the server, then searches the result for the next key.
This is very network intensive, but good enough for the work in progress that this is.

So the request is to ensure there is an index.json on each page.

Originally, I was using some html parser (BeautifulSoup) to find the hrefs, and I guess one could simply build the paths once off, then reference that from that object…

Then the flow would be:

  1. Get index.json
  2. Get business href page, store and parse this for easy ref
  3. Get whatever object you want with those reff’s.

Another option, would be to have the root index.json actually contain the entire object path tree… Not sure how that sounds. But I think it is probably un-RESTful…

Any thoughts?

Am I correct in thinking we only have a tree depth of 4 here?

Reading over this now, maybe option 2 is best. More coding, but it’ll be less network intensive and will give you less work:-P

Cheers:-)

Hey @lubos

So I implemented some code, that works nicely with this. You can check it out in the repo.

It only pulls so far.

And. It crashes the server. I think I make too many requests…

Let me know if i can give you logs or something.

Hey @lubos,

Better login

More report back. I have fixed my script to use sessions. Only one login attempt:-)

BUG!!

More importantly, I figure out why the crash.

I was requesting the object without the final .json, this causes the server to crash, even in the browser, so should be easily reproducible.

Can handle the traffic

Now that I am requesting the right thing, I see the server can handle me requesting each of my 400+ customers. It just takes a long time.

Thanks again, this is a fantastic start.

Maybe, I can thread the requesting of the objects… Hmmmm.

The Script is now located below:

Is there documentation for the API?

Lubos can answer this better than I, but I think documentation does not yet exist. However, if you visit the API page in your browser, you can get a summary of how it works. It’s pretty simple. I like it.

You are also free to look at my code above, it has some notes in it, and may help you understand how things are working. I have yet to implement PUT and POST though.

On that note, I’m wondering if manager will accept anything in the PUT and POST? Or will it validate the data first? @lubos

–EDIT–
Just realised I broke the link. It’s fixed now, sorry everyone.

@lubos

Any word on work with the API? I still cannot create a receipt for an invoice, as the accountsReceivable account is not actually listed in the API page.

I’m guessing the API is going through some changes?

Whatever Manager can create, you can also create via API.

What I suggest is to create transaction in Manager, then look how it was saved in API.

In this case, Accounts Receivable account is in-built. It doesn’t have to be listed in API as an account. Manager has a few in-built accounts where GUID of the account is the same across all businesses. So you can use that GUID even without this account being explicitly created.