Topic: Simple REST API

Hi all, i just released a simple REST API Module for Front Accounting.

I need to create some basic integration functions with another software so i created this public repository on GitHub.
I am using Slim FrameWork to create the REST API and trying to use FA Coding Standards.

Simple REST API Repository:
https://github.com/andresamayadiaz/FrontAccountingSimpleAPI

Hope you like it, i will be uploading changes as soon as i finish them, if you have any ideas or suggestions they are always welcome, and also if you find some bug, please let me know: andres.amaya.diaz@gmail.com

Re: Simple REST API

Thanks a lot!

Wikied it.

It now places FA on par with webERP in one critical aspect. It also paves the way for POS connector, etc.,.

Re: Simple REST API

There is also a couple of other implementations for SOAP and REST API available on our download page. None of them has full FA db scheme support though.

Janusz

4 (edited by apmuthu 10/16/2012 02:11:13 pm)

Re: Simple REST API

Thanks Janusz, Wikied that link as well.

Re: Simple REST API

SimpleAPI - can synch different FA instances as well - looking at High Availability clusters across data centres and local power outages!

Re: Simple REST API

Updated the SimpleAPIModule Wiki page with a read example that can be executed from an external server.

Post's attachments

FA_SlimAPI_test_Read.zip 796 b, 17 downloads since 2012-10-18 

You don't have the permssions to download the attachments of this post.

Re: Simple REST API

Updated Read Test File.

Post's attachments

FA_SlimAPI_test_Read.zip 938 b, 12 downloads since 2012-10-18 

You don't have the permssions to download the attachments of this post.

Re: Simple REST API

I just started working on this features for the API
GET /customers/:id/branches --> Get a list of customers branches where customer id = :id
GET /suppliers/:id/contacts --> Get a list of supplier contacts where supllier id = :id
POST /inventoryadjustments/ --> Create a new inventory adjustment ( can contain multiple items )

Then the roadmap will be:
GET /salesquotes/:id --> Get sales quote info
GET /salesorders/:id --> Get sales order info
POST /salesorders/ --> Create new sales order

NOTE: I am not using PUT requests, i replaced PUT requests with POST using id as parameter. I know this is not standard REST but works for me now, maybe in the future i can change it.

9 (edited by apmuthu 10/19/2012 02:03:34 am)

Re: Simple REST API

Thankyou Andreas. Your work is simply fantastic. PUT may allow encryption, POST may not. If you can get PUT to work, then we can not only ensure standard REST, but also progress with the protocol changes as it occurs.

I am trying to fathom and document the external server side to be able to interact with SimpleAPI.

Maybe another SimpleAccessAPI project would dovetail to interface with FA thru the SimpleAPI extension.

This, I hope will be the basis for a full fledged Open Source POS connector / system that FA currently lacks natively.

Multiple branches maintaining transactions pertaining to their branch only (Dimension / Profit Centre) can synch / post to a central head office FA for consolidation or choose to synch fully every few minutes or in realtime (bandwidth and latency issues) so that all can work locally and yet use all of the same data.

Also compiled (GTk, VB, C++, etc) clients for FA would soon be possible.....

10 (edited by andresamayadiaz 10/22/2012 11:03:19 pm)

Re: Simple REST API

Hi again. Just wanted to keep you informed, i just publish some commits that now contains this methods in the API

GET /customers/:id/branches --> Get a list of customers branches where customer id = :id
GET /suppliers/:id/contacts --> Get a list of supplier contacts where supllier id = :id
GET /currencies/ --> Get a list fo currencies
GET /exrate/:id --> Get the latest currency rate with home currency where id = currency_code
GET /itemcosts/:id --> Get the standard cost of an item where id = :id
POST /itemcosts/:id --> Update the standard cost of an item where id = :id

... aad

11 (edited by apmuthu 10/23/2012 04:59:17 am)

Re: Simple REST API

Line 372 in index.php :

$rest->post('/itemcosts/', function() use ($rest){

should be:

$rest->post('/assets/', function() use ($rest){

The Wiki Page stands updated.

Attached herein is the updated api.zip file with this fix ready to go into the modues/api folder.

Post's attachments

api.zip 173 kb, 11 downloads since 2012-10-23 

You don't have the permssions to download the attachments of this post.

Re: Simple REST API

Sorry about that, i just push the change to github.

... aad

Re: Simple REST API

Thanks Andres, reflected it in the Wiki.

Since POST(Edit) and DELETE use the same syntax, how does the API distinguish between the two? If the POST has no field data is it to be assumed to be a DELETE?

A sample php usage to demonstrate putting in data into FA would be nice.

14 (edited by andresamayadiaz 10/24/2012 02:33:29 pm)

Re: Simple REST API

As soon as i got some time i can work on an example client, probably using this: http://phphttpclient.com/ but for a quick testing you can use this: https://code.google.com/p/rest-client/ it is a REST Client, i am actually using this to test the Simple REST API.

About the POST and DELETE that depends on the HTTP Method used on the request, i wrote in a previous post that i am not using PUT requests this is not the standard REST and soon i am going to change it. You can get more information about CRUD operations in a REST API here: http://en.wikipedia.org/wiki/Create,_read,_update_and_delete

Also i want to comment that if any of you remember webERP they started some years ago to implement a JAVA POS using an API, they used synPOS, and maybe we can use this same POS (i have the source code) to create a POS system for FrontAccounting using Simple REST API and synPOS.

... aad

Re: Simple REST API

synPOS v0.9.3 was the last released version on 2006-11-07.

POSxp looks promising and seems current.

Will check out the REST clients listed. I just wanted to know the way the API would distinguish between similar Select Specific, Edit and Delete URLs since all requestes would come thru the URL parts only. At least the Edit would have a POST array, the Select Specific and Delete requests would be similar.

Re: Simple REST API

Hi,
I'm the creator of PosXp, I came across this thread and from what I understood you are talking of an API to exchange data via HTTP with the frontaccounting db.
I just would like to let you know that posxp has a data layer library to permit interfacing with any data provider different from the default one which is a SQL compact db.
So you can easily rewrite this layer to interface with the software.
Regards

Alberto

Re: Simple REST API

Hi, that sounds great, just a question, PosXp needs .NET FrameWork, have you done some testing using Mono.NET ?

It would be great that the POS can be used in linux and mac as well.

.. aad

18 (edited by alberiv80 10/24/2012 10:09:03 pm)

Re: Simple REST API

yes of course I've tried wink
I remember that I was able to run it, but if I remember well controls were a bit crashed, something to do with spacing etc....
Anyway my conclusion was that it was not sufficiently good.
Also the software was created to be a cash register OS over wepos/windows embedded, so it's just too much distorting to run it on windows desktop too.
I'm a linux fan either but for POS applications windows it's a better choice, also for pos devices.
On linux the only alternative would be Java and Java POS for devices but java GUIs are horrible and the software it's designed to be completely used with touch screen so I made myself draggable listboxes etc....

19 (edited by apmuthu 10/28/2012 02:10:55 pm)

Re: Simple REST API

Thanks Andres for starting out on PUT....

It would be useful to put in the Wiki Page URL in the README file in the GitHub so that users can partake of the updated Wiki.

https://frontaccounting.com/fawiki/index.php?n=Devel.SimpleAPIModule

Post's attachments

api.zip 283.2 kb, 3 downloads since 2012-10-28 

You don't have the permssions to download the attachments of this post.

20 (edited by apmuthu 11/29/2012 06:36:24 am)

Re: Simple REST API

SimpleAPI Module Wiki Page has been updated with a full test access script set for remote FA server access.

Post's attachments

FA_SlimAPI_test_Access.zip 1.4 kb, 11 downloads since 2012-11-29 

You don't have the permssions to download the attachments of this post.

21 (edited by apmuthu 04/07/2013 01:07:02 pm)

Re: Simple REST API

@andresamayadiaz:
Your recent GitHub change has an error in line 14 of inventory.inc:

include_once($path_to_root . "/gl/includes/dl_db.inc"); 

should be

include_once($path_to_root . "/gl/includes/gl_db.inc"); 

The included file name is gl_db.inc and not dl_db.inc

Re: Simple REST API

Thanks for this. I'll change it as soon as possible and let you know.

Andres

Re: Simple REST API

The Repository has been updated with the BUG FIX.

... aad

Re: Simple REST API

The account numbers for the Journal Entries are hardcoded in inventory.inc - lines 321-323 are:

             // TODO Obtener cuentas contra las cuales hacer asientos
             $_SESSION['gl_items']->add_gl_item('1510', 0, 0, ($info['quantity']*$info['standard_cost']*-1), $info['memo']); // Cta de Inventario del Producto
             $_SESSION['gl_items']->add_gl_item('4010', 0, 0, ($info['quantity']*$info['standard_cost']), $info['memo']); // Cta Configurada para Obsolteos, Propios, etc ...

The comments are in Spanish - Please make it in English.

25 (edited by ecogtip 04/30/2013 09:33:57 am)

Re: Simple REST API

Not sure what I'm missing however using Http://YOUR_FA_URL/modules/api/category/ returns 404 when omitting index.php. This was consistent  in both IIS7 and Apache2 with php5.4

I was able to make it work with Http://YOUR_FA_URL/modules/api/index.php/category/