# Sending POST requests from the Core

**URL:** <https://community.particle.io/t/sending-post-requests-from-the-core/11188>\
**Category:** Getting Started\
**Created:** [April 9, 2015, 7:46pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188 "2015-04-09T19:46:42Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![seemanta](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/seemanta/32/5084_2.png) [@seemanta](https://community.particle.io/u/seemanta)\
**Post date:** [April 9, 2015, 7:46pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/1 "2015-04-09T19:46:42Z")

</div>

Hi,  
I am very new to Spark and before I commit myself to use this in my project, I want to know if it is possible to do what I have in mind.

Here is what I am planning to do:

1. Monitor a physical variable, like say, for example the water level of my water tank every minute. I want to log this information via a streaming service: [https://www.initialstate.com/streaming](https://www.initialstate.com/streaming)  
This service allows me to post my variables to their cloud based system.

2. In case the monitored variable goes beyond a certain value, I want an email/tweet to be sent out to me, as a warning.

Both 1 and 2 are easily achieved via python if I use a raspberry Pi hooked up to my sensor. But I want to achieve everything via the Spark. This keeps my project small and web enabled from the get-go.

The question is: is this doable.

I read the API documentation. I know I can GET and POST urls to my core. But how do I make my CORE itself do a POST request to the streaming service webserver?

And how do I get the core to send out a tweet? Are there libraries that I can use for this purpose?

Thanks for your patience in reading my post.  
Have a good day.  
Seemanta

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [April 9, 2015, 7:57pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/2 "2015-04-09T19:57:38Z")

</div>

@seemanta, since the Core cannot do https directly, you can now do GET/POSTs using [webhooks](http://docs.spark.io/webhooks/). These allow you use use Spark.subcribe()/publish() to send or get data from any website to and from the Core. A neat new feature recently added is the ability to have the Cloud do a JSON parse on return data so you only get what you want from the payload, removing the need to do JSON parsing in the Core.

---

<div class="post-metadata">

**Author:** ![aaltieri](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@aaltieri](https://community.particle.io/u/aaltieri)\
**Post date:** [April 10, 2015, 1:37pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/3 "2015-04-10T13:37:50Z")

</div>

Can webhooks be used with the local cloud?

I’m looking at using the Photon for monitoring some things, but security is an issue for me. So I need to be able to push data from the photon in real time, but I can’t use the public cloud.

–anthony

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [April 10, 2015, 1:49pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/4 "2015-04-10T13:49:41Z")

</div>

@aaltieri, the local cloud does not yet support webhooks. However, webhooks and all related data is secured like all other public Cloud transactions.

---

<div class="post-metadata">

**Author:** ![aaltieri](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@aaltieri](https://community.particle.io/u/aaltieri)\
**Post date:** [April 10, 2015, 1:52pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/5 "2015-04-10T13:52:24Z")

</div>

Is there an ETA? I can’t have these devices connected to a public network at all.

–anthony

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [April 10, 2015, 2:03pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/6 "2015-04-10T14:03:34Z")

</div>

@aaltieri, perhaps @Dave can clarify. If you cannot connect to a public network, you may want to consider using TCP only. If you search the forum, you will find examples like this one:

> **[AES encryption demo and secure TCPClient usage](https://community.particle.io/t/aes-encryption-demo-and-secure-tcpclient-usage/6092)**
>
> Here’s a little demo that you can paste into Spark Build that shows how to use the AES-128-CBC encryption already available in the Spark Core firmware. Put that on a Core and watch what it says on Serial. Once every 10 seconds it will create a...

---

<div class="post-metadata">

**Author:** ![seemanta](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/seemanta/32/5084_2.png) [@seemanta](https://community.particle.io/u/seemanta)\
**Post date:** [April 10, 2015, 6:31pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/7 "2015-04-10T18:31:50Z")

</div>

Sorry, this might seem like a very stupid question, but what is a local cloud?

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [April 10, 2015, 6:58pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/8 "2015-04-10T18:58:30Z")

</div>

The “[local cloud](https://github.com/spark/spark-server)” is a version of the full Spark Cloud you can run on a local computer such as a Raspberry Pi for example. Though it does not support all the functions of the full Cloud, it can be used where internet connectivity to the Spark Cloud is not available or not desired. 😄

---

<div class="post-metadata">

**Author:** ![aaltieri](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@aaltieri](https://community.particle.io/u/aaltieri)\
**Post date:** [April 10, 2015, 7:33pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/9 "2015-04-10T19:33:18Z")

</div>

This is very helpful, thanks!

–anthony

---

<div class="post-metadata">

**Author:** ![seemanta](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/seemanta/32/5084_2.png) [@seemanta](https://community.particle.io/u/seemanta)\
**Post date:** [April 10, 2015, 10:51pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/10 "2015-04-10T22:51:23Z")

</div>

Jeez, I am such an idiot. Thanks for answering my questions patiently 🙂  
I appreciate it.

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dave/32/181_2.png) [@Dave](https://community.particle.io/u/Dave)\
**Post date:** [April 11, 2015, 11:29am UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/11 "2015-04-11T11:29:19Z")

</div>

Hi @aaltieri,

If you need this to be entirely local only and want to use the local cloud, you can always add something like webhooks behavior to the local cloud quickly. I’m hoping to sketch out a better interface for extending the local cloud, but if you installed it / got your core connected to that locally, you could do something like…

> <https://github.com/particle-iot/spark-protocol/blob/master/js/clients/SparkCore.js>

```auto
// etc
if (lowername == "my/event") {
  var request = require('request');
  request({ url: "https://mysite.foo/api" ... });
}

```

Thanks!  
David

---

<div class="post-metadata">

**Author:** ![ruben](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@ruben](https://community.particle.io/u/ruben)\
**Post date:** [May 7, 2015, 11:09pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/12 "2015-05-07T23:09:21Z")

</div>

This is Awesome! It will hopefully help me greatly.I’ll find out tonight. Will post in Cloud JSON Parsing or Here.

---

<div class="post-metadata">

**Author:** ![AshtonJ](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@AshtonJ](https://community.particle.io/u/AshtonJ)\
**Post date:** [July 30, 2015, 9:51pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/13 "2015-07-30T21:51:49Z")

</div>

Has there been any update on webhook functionality being added to local cloud (spark-server)?

---

<div class="post-metadata">

**Author:** ![xlarge](https://avatars.discourse-cdn.com/v4/letter/x/2bfe46/32.png) [@xlarge](https://community.particle.io/u/xlarge)\
**Post date:** [March 10, 2016, 4:01pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/14 "2016-03-10T16:01:56Z")

</div>

Haven’t found anything regarding this so here comes the mother of a bump:

Webhooks in the spark-server local cloud: Boy wouldn’t it be nice!

Will appreciatively accept trouts of wisdom slapped in my face about what i couldn’t find where.

---

<div class="post-metadata">

**Author:** ![Jolley71717](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/jolley71717/32/15872_2.png) [@Jolley71717](https://community.particle.io/u/Jolley71717)\
**Post date:** [December 1, 2017, 4:50am UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/15 "2017-12-01T04:50:47Z")

</div>

Have you found any more information on spark-server local cloud webhooks?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [December 1, 2017, 7:43am UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/16 "2017-12-01T07:43:14Z")

</div>

You may want to look into @Brewskey’s heavily enhanced fork of the local cloud server

> **[Brewskey/spark-server](https://github.com/brewskey/spark-server)**
>
> spark-server - An API compatible open source server for interacting with devices speaking the spark-protocol

---

<div class="post-metadata">

**Author:** ![Brewskey](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/brewskey/32/11322_2.png) [@Brewskey](https://community.particle.io/u/Brewskey)\
**Post date:** [December 8, 2017, 3:17pm UTC](https://community.particle.io/t/sending-post-requests-from-the-core/11188/17 "2017-12-08T15:17:05Z")

</div>

I really just need to do a PR to the main Particle repo so you don’t have to keep referencing our fork 🙂
