REST Services in Squirrel?

Much of what I will be doing with the imp is pulling sensor data, processing it using third party REST services, then sending the results back down to the imp for display on an LCD.  I have looked for examples on how to hit REST services with Squirrel and can’t seem to find anything.  The examples on the Wiki are great but don’t have any REST stuff. I see that there is a Soft Imp node that suggests POST/GET but I’m unclear on how I might parameterize the URL.  Can someone help me out please?

The REST stuff is on the server end, not the squirrel end; you use a IO block in the planner to provide the HTTP to event conversion.

These are very early versions, but:

HTTP in: allows you to send arbitrary values or strings to the planner, from where you can connect them to imps. Click the slider button on the block to see the URL you need to hit to do this.

HTTP POST: will POST to a URL that you enter on the config page.

I’ve got the HTTP IN working well, but can’t seem to get a node to connect to the HTTP POST node in the planner. I keep getting “This impee has no sync nodes you can connect” but am not entirely sure how to establish/build a sync node. Any help?

Something like this…

local httpPost = OutputPort("Post", "string"); imp.configure("My Impee", [], [ httpPost ]); httpPost.set("Hello, web!");

Fen Consultants, UK

We should totally find and fix all the places where it still says “sync” when it means “sink”.


It referred to inputs and output when I looked this morning…

In any case HTTP Post would require a source not a sink, so not sure what’s up here.

Fen Consultants, UK

Thank you for your help, Rob, but things still aren’t working for me. I can’t seem to figure out how to use the HTTP Post node. Any pointers?

To give more detail, I create a node but can’t actually get it to noodle to the HTTP Post node without the error. Any thoughts?

I plan to write HTTP In and HTTP Post example scripts at some point over the weekend, including use of the Planner to configure them, so if you haven’t solved it by then hopefully those will help.

Fen Consultants, UK

Thanks Rob! That will be great!

There’s an example online now.  It uses the Hannah temperature sensor, but could easily be modified to log something else if you don’t have a Hannah.

However refer to the other thread for info about your “sync error” - I believe it’s a planner bug which you can work around. Your code is probably fine.

Fen Consultants, UK

Can you please post the URL for the example?

All the examples are on the development wiki:


Great example. Thanks for the work you put in to that.  I have a clarifying question to help me completely grok the example. If I understand correctly you configure the HTTP POST vimp with the base URL for the web-service. The information sent from the imp will be concatenated on to the base URL that will then be sent to the server.  So if I’m watching from the server I should see something like this coming in every 5 seconds -

which is the result of this function call -


So if I am working with a server where I need to pass a series of parameters (e.g., ?value=6&user_id=342123&device_id=4598243) I would do so by concatenating them all together and then sending them out using output.set.  Yes?

No, that’s not how it works right now. The URL is a fully defined path to a page that can accept a POST connection. Currently only one value is transfered, in the “value” field. Of course this could be anything - including a combination of several parameters in some format decided by you.

What you’re getting at above would be an HTTP GET. There isn’t a GET vimp yet, and you can’t subvert the POST vimp because the URL can only be set manually in the Planner right now. However I believe I saw Hugo mention a GET vimp may come later.

Fen Consultants, UK

Check out this thread for a more rounded response to this thread.