The Manager API

Hey @lubos,

Yes, you are right, that was badly worded. I can create receipts, I just thought there may be a better way coming soon.

I will hard code this for now, but I hope in future this will be query-able? Along with having the ability to GET all the Invoices/Customers at once? :smiley:

@lubos, I guess another way of dealing with finding a certain entry/customer/invoice is to enable searching through the api. Though, I don’t know how much processing load this would put on the hosting server.

I guess the extremes are, be able to search everything, or, be able to basically download everything in one go as json.

Problem with bulk download, is if there are changes between the time that the download occurs, and when the info is used, it could lead to issues. So maybe search terms would be good?

I’d prefer if API would remain RESTful and I’m not sure how search would fit RESTful philosophy. I’d have to look this up.

I’m not very concerned about how much load it puts on the server as it always depends.

Hey @lubos,

So, because it’s me we are talking about, at the risk of being redundant, and learning something, I went and looked up the RESTful API structure a bit.

I think adding parameters to the query string will make the API more RESTful, for 2 reasons:

  1. Server client separation: If the client has to request all the data in order to find one object, then it’s basically becoming concerned with data storage, which is not restful.
  2. Cache-able: if the client needs to request all customers to find one, then there is a large chance of the requested data going stale.

So, maybe something like this would work?

  • GET /api/<business_id>/<Customer_collection_id>?name=fred
    Which could then return all the customers with Fred in their name.

  • GET /api/<business_id>/<SalesInvoice_collection_id>?reference=<ref>
    Get all the invoices with ref.

I guess you could extend it to include multiple search parameters too:

  • GET /api/<business_id>/<SalesInvoice_collection_id>?customer=fred&date=2016

Or better yet:

  • GET /api/<business_id>/SalesInvoice?customer=fred&date=2016

Anyway, just my 2 cents. :slight_smile: I hope it’s helpful!

EDIT

This may be helpful.

2 Likes

Is it done for now?
i want to make 3rd app for POS thet prefer to Manager.

For me, anything would work: CRUD, RESTfull, SOAP, XML, JSON, etc.
(as long as it’s an API of course)
:wink:

I’m having a lot of fun playing with the API. Great work!

A RESTful search would indeed be implemented as procsum wrote above:

GET /api/<business_id>/<SalesInvoice_collection_id>?Reference=<ref>

This would return an array of JSON objects (the sales invoices).

To keep things simple, I would only search by actual field contents. So a search for a certain customer in an invoice, I’d do by:

GET /api/<business_id>/<SalesInvoice_collection_id>?To=<Customer-UUID>

One detail I saw, the API returns data nicely in UTF-8. The Content-Type header is ‘application/json’. I’d change that to ‘application/json; charset=utf-8’ so that no content sniffing or hardcoding utf-8 in API consumers is necessary. The same goes for the HTML index pages, here no Content-Type header is added (should be ‘text/html; charset=utf-8’).

PS: my use case is that I’m trying to import all my bank statements and invoices since 2010 into Manager using some custom PHP scripting, including linking the invoices to customers and payments. I know I could use a starting balance, but I’m suffering from a mild case of obsessive structuring I’m afraid… :wink:

Cool. I assume you’re referring to the Server Edition; correct?
I’m asking because on the Desktop Edition, I just see 403 Forbidden when accessing http://127.0.0.1:randomport/api/ as it keeps popping up HTTP authentication dialog. I think it’s due to the fact that the Desktop edition does not support user-based credentials.

Correct, I installed the server version of Manager on Ubuntu 16.04 in VirtualBox. Setup was smooth. Only use the server edition for the API right now, the plan is to put the backup back on Desktop after I’m done.

But I have to say that having a decent API on good accounting software is a lot of fun. Offers a lot of opportunities.

Oh I do recall the joys of playing with incandescent APIs for the first time e.g. Instagram, Stripe and Paypal.

Currently, I have written dummy tools to download data and generate CSV files automatically but I have to import the statements manually.
If Server Edition’s API does the wonders, I guess I’ll switch to it after playing with it for a while :smile:

Check my Manager.io PHP API client. You can add customer to manager.io by passing variables in customer class.
GitHub - kennethmervin01/managerio: Manager.io API Helper

example:

$customer = new Managerio\Customer();
$customer_data = array(
    "Name" => "Bruce Wayne XXIX", // Full Name of the Customer
    "BillingAddress" => "Gotham", // Full Billing Address
    "Email" =>  "baty4@gmail.com", // Email 
    "BusinessIdentifier" =>  "001 001 511", // Business Identifier (TIN,TAX ID , etc)
    "StartingBalanceType" => "Credit" // Default Value of Manager.io
);

/**
 * Add Customer
 * It will return the new json link of the new customer in Manager.io.  
 * You can save it to your database  so you can have a connection between manager.io and your current app.      
*/
$new_customer = $customer->addCustomer($customer_data); 

@Kenneth_Mervin So basically, if one wanted to have quick access to anything in managed, they would pretty much want to replicate the manager keys, with a few fields, in their own database?

Hmmm. It does mean the script one writes has to be a whole lot more intelligent than a simple GET .../customers?search="fred" but that’s okay.

@lubos Do you see much movement in the API over the next couple of months? I do not see it in the roadmap, so is it safe to assume it will stay the same for a while yet?

The problem is that search parameter would cover very narrow set of use-cases. It still wouldn’t solve whole lot.

The idea is to complete implementation of “custom reports” and then make results from custom reports accessible from API. That would be general purpose solution which would cover search parameter and much more.

Is it possible to make Json POST/PUT return result? Such as successful message with key of the record.

For PUT you don’t need to know the key since you are already supplying key.

As for POST, Manager returns location of newly created record in Location response header.

1 Like

Thanks Lubos for the clarification. There’s some great points here to think through for me to make good use of the API. :thumbsup:

Thanks for help. I forgot to check the headers. now problem solved.

I’m a nube, thinking about moving from MYOB.
Would just like to ask if API posting to invoices, spend money, receive money is reliably implemented at this stage using multicurrencies?
Regards…

@bobferg API allows to create any type of entry. However it’s still in experimental stage. What it means is that API will still continue to evolve a bit.

You can save the data that was put/post in manager.io , plus the name of the customer and I add CustNo in customer fields.
My table looks like this
Customer Table:
----- ID ------- CustNo ---------------- Name-------------------------- api_key ------------------ api_data
-----1 ---------- PH01 -----------Kennnet Mervin ------------- 084456622e012---------{object i pass in manager}

Then in my app If I want to search customer by name/CustNo I use my php/sql.

//By Name
$result  = query("Select * FROM customer WHERE `Name` LIKE %Ken%");

Then I create a class in Managerio called Manual

$manager = new Managerio\Manual;

//return  all the api key in index.json of Customer folder
$manager->getList("Customer"); 

// from $result 
foreach($result as $data){
    // return data from managerio.api
   $customer = $manager->getList("Customer",$data['api_key']); 
   var_dump($customer)
}

That’s how i implement my own search with the help of my own database… Actually I can now create invoice, receive money, spend money just using managerio api with the help of my database :smiley: