You are not logged in.

#1 2016-03-16 01:48:54

jeff
Member
Registered: 2016-02-23
Posts: 12

Exposing APIs for external invocation

Currently 16x2 LCD looks too simple, I'm thinking what if I implement a big touch screen with some external development, where we can power on/off projector, select/print usb file (also support stop/pause/resume print). Is this possible?

Offline

#2 2016-03-16 02:52:24

Shahin
Administrator
Registered: 2016-02-17
Posts: 1,834

Re: Exposing APIs for external invocation

We have a similar request from one of printer manufacturer which we are working on. It is already possible to hack things together but any change on our side could break things on the other side.
I am middle of pretty sizable new features after that I will check to see if we could stabilize things and release API.

Offline

#3 2016-03-19 09:24:43

Shahin
Administrator
Registered: 2016-02-17
Posts: 1,834

Re: Exposing APIs for external invocation

Jeff,

Lets go through requirements.

We already have /status and /log paths which are representing current status of the printer, both are pretty stable.
First one is JSON second one is JSON streaming

For control API itself we need following things

  • API Versioning /api/v1/

  • Access control - Do you have suggestion about how it should token be generated as it is not public webservice? and probably rpi and display will be sitting in the same box

  • List Plates - /api/v1/plates

  • Printer actions - /api/v1/printer/{shutdown,restart,stop,pause,resume}

  • Projector actions - /api/v1/projector/{on,off}

  • Shutter actions - /api/v1/shutter/{on,off}

  • Plate get info - /api/v1/plate/id

  • Plate actions - /api/v1/plate/id/{delete,print}

  • USB file listing - /api/v1/usb

Anything else?

Offline

#4 2017-06-07 14:03:28

juliendelnatte
Member
Registered: 2017-06-07
Posts: 80

Re: Exposing APIs for external invocation

Any news about this? would like to use the API to make an iPhone App, LCD screen,...

Offline

#5 2017-06-08 07:13:13

Shahin
Administrator
Registered: 2016-02-17
Posts: 1,834

Re: Exposing APIs for external invocation

Routes on NanoDLP are pretty stable. You can use current routes instead of waiting for separate API. I know couple of private app already developed to work with nanodlp without any issue.

Offline

#6 2017-06-08 09:27:41

juliendelnatte
Member
Registered: 2017-06-07
Posts: 80

Re: Exposing APIs for external invocation

wich routes are you talking about? Html result routes? so I have to parse html data to get, by exemple : plates? or call an html routes to move the Z axis and not have results,...?

Offline

#7 2017-06-08 12:07:47

Shahin
Administrator
Registered: 2016-02-17
Posts: 1,834

Re: Exposing APIs for external invocation

No, you do not need to deal with html.

For list of plates there is separate path to get json instead of HTML. I will share complete list below.

GET /
GET /login
POST /login
POST /add-protection
POST /online-access
GET /camera/take
GET /printer/off
GET /printer/auto-shutdown/:mode
GET /printer/restart
GET /printer/terminate
GET /printer/restore
GET /printer/upgrade
GET /printer/upgrade/go/:version
GET /printer/distro/:distro
GET /printer/expand-fs
GET /printer/cast
GET /printer/stop
GET /printer/force-stop
GET /printer/pause
GET /printer/unpause
GET /printer/resume
GET /printer/start/:PlateID
GET /printer/ip
POST /printer/start/:PlateID
GET /setup
GET /setup/export
POST /setup/import
POST /setup/fetch
GET /setup/custom-inputs
POST /setup/custom-inputs
POST /setup
POST /setup/save-custom-inputs
POST /buttons/save
POST /add-mask
GET /button/press/:ID
GET /plates
GET /plate/add
GET /plate/add-usb
GET /plate/add-support
GET /plate/edit/:PlateID
GET /plate/delete/:PlateID
GET /plate/preview/:PlateID
GET /plate/cover/:PlateID
GET /plate/download/:PlateID
GET /plate/regenerate/:PlateID
GET /plate/3d/:PlateID
GET /plate/generator
GET /plate/layer-generator
GET /plate/paint
GET /plate/paint/add
POST /plate/paint
POST /plate/cover/:PlateID
POST /plate/add
POST /plate/add-usb
POST /plate/add-support
POST /plate/edit/:PlateID
POST /plate/generator
POST /plate/layer-generator
POST /plate/paint/add
GET /profiles
GET /profile/add
GET /profile/edit/:ProfileID
GET /profile/clone/:CloneID
GET /profile/delete/:ProfileID
GET /profile/export/:ProfileID
GET /import
GET /profile/default/:ProfileID
POST /profile/import
POST /profile/fetch
POST /profile/add
POST /profile/edit/:ProfileID
POST /profile/clone/:CloneID
GET /projector-calibration
GET /projector/display/:image
GET /projector/generate/:image
GET /projector/on
GET /projector/off
GET /projector/blank
GET /projector/lamp
GET /shutter/open
GET /shutter/close
GET /mask/form
POST /mask/grid
POST /mask/generate/:type
GET /z-calibration
GET /z-axis/move/:directon/:type/:amount
GET /z-axis/top
GET /z-axis/bottom
GET /z-axis/touch-limit
GET /z-axis/calibrate
GET /z-axis/enable/:mode
GET /ramps/reconnect
GET /term-io
GET /wifi
POST /wifi/connect
POST /term-io
POST /z-calibration
GET /debug
GET /debug/continue
GET /debug/stack
GET /status
GET /slicer
GET /log
GET /page/:file/:title
POST /save/partial
GET /help/:files
GET /term
GET /device.xml
GET /initGPU
GET /json/db/:file
GET /json/usb
GET /json/wifi
GET /help
POST /formula
POST /gcode

Offline

#8 2017-06-08 12:20:07

juliendelnatte
Member
Registered: 2017-06-07
Posts: 80

Re: Exposing APIs for external invocation

When I go to 127.0.0.1:8080/plates on windows, it give me HTML result and not json

Offline

#9 2017-06-08 12:24:00

Shahin
Administrator
Registered: 2016-02-17
Posts: 1,834

Re: Exposing APIs for external invocation

/json/db/plates.json

Offline

#10 2017-06-08 12:29:36

juliendelnatte
Member
Registered: 2017-06-07
Posts: 80

Re: Exposing APIs for external invocation

Ok thx, so everything else is html to parse?

Offline

#11 2017-06-08 19:05:21

Shahin
Administrator
Registered: 2016-02-17
Posts: 1,834

Re: Exposing APIs for external invocation

No you could find json for response for every action you need. Like shared one for plates file which is in json format.

Offline

#12 2017-06-09 06:46:53

juliendelnatte
Member
Registered: 2017-06-07
Posts: 80

Re: Exposing APIs for external invocation

Ok, but how? for exemple : http://127.0.0.1:8080/shutter/open of printer/stop,... how can I can get json response instead of html?

Offline

#13 2017-06-09 06:53:28

Shahin
Administrator
Registered: 2016-02-17
Posts: 1,834

Re: Exposing APIs for external invocation

These are action routes. No response from these routes (no HTML or JSON) they just trigger requested action.

Offline

#14 2017-09-02 10:02:41

Gatto
Member
Registered: 2017-02-14
Posts: 72

Re: Exposing APIs for external invocation

Can you add something plate/add/ profileno description ZipFile ?

will be nice to automate plate preparaton from remote

Thanks

Offline

#15 2017-09-02 19:49:12

Shahin
Administrator
Registered: 2016-02-17
Posts: 1,834

Re: Exposing APIs for external invocation

You can already post data to the same url and it will be added as a plate.

Offline

#16 2017-09-03 07:58:43

Gatto
Member
Registered: 2017-02-14
Posts: 72

Re: Exposing APIs for external invocation

Shahin wrote:

You can already post data to the same url and it will be added as a plate.

Can you please share the post format or an axample?

Thank you

Offline

#17 2017-09-03 18:41:14

Shahin
Administrator
Registered: 2016-02-17
Posts: 1,834

Re: Exposing APIs for external invocation

Open your browser inspector tool, select network tab upload file and checkout request. Even you can copy request in CURL format.

Offline

#18 2017-09-04 07:40:58

Gatto
Member
Registered: 2017-02-14
Posts: 72

Re: Exposing APIs for external invocation

Shahin wrote:

Open your browser inspector tool, select network tab upload file and checkout request. Even you can copy request in CURL format.

Hmmm, looks like I have to stream file, but I do not know how...

------WebKitFormBoundarykP2QVaXD0g1yWvnp
Content-Disposition: form-data; name="Path"

tavola 7
------WebKitFormBoundarykP2QVaXD0g1yWvnp
Content-Disposition: form-data; name="ProfileID"

4
------WebKitFormBoundarykP2QVaXD0g1yWvnp
Content-Disposition: form-data; name="USBFile"


------WebKitFormBoundarykP2QVaXD0g1yWvnp
Content-Disposition: form-data; name="ZipFile"; filename="tavola 7.stl"
Content-Type: application/octet-stream


------WebKitFormBoundarykP2QVaXD0g1yWvnp--

Offline

#19 2017-09-04 19:26:57

Shahin
Administrator
Registered: 2016-02-17
Posts: 1,834

Re: Exposing APIs for external invocation

It is just enctype="multipart/form-data"

Offline

#20 2017-11-12 12:24:01

Gatto
Member
Registered: 2017-02-14
Posts: 72

Re: Exposing APIs for external invocation

Shahin wrote:

No, you do not need to deal with html.

For list of plates there is separate path to get json instead of HTML. I will share complete list below.

......

I'm using json/db/file.ext to download files from db folder to local, is there a way or can you implement something to upload a file also into arbitrary folder?

I'm managing actually using side sw but will be nice to have it into your engine

Thanx

Gatto

Offline

#21 2017-11-12 14:50:39

Shahin
Administrator
Registered: 2016-02-17
Posts: 1,834

Re: Exposing APIs for external invocation

Only DB file could be replaced by uploading directly. No way to replace  other files on disk.

Offline

Board footer

Powered by FluxBB