@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?
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:
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.
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
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…
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
$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.
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