Spark.publish() parameters being passed?


#1

I am working with spark.publish(). I see in the example of the .HTML file several parameters passed, CoreID, data, published_at. Where can I find information on these and whatever else is available?

Thanks,


#2

Here is the doc section for that:

http://docs.spark.io/firmware/#data-and-control-spark-publish

If you have other questions, feel free to ask!


#3

Yes, I do, thanks…

I looked in the doc section but it does not contain the information I am asking about. I am not referring to the parameters passed in the Spark.publish() statement but the parameters imbedded within the function.
In your .HTML code you are receiving the CoreId, data and published_at. I see that Data is being passed. But i don’t see where CoreID and published_at are coming from. I assume they are imbedded within the function. My question is how would I know that and are there any others? Or what is triggering CoreID and published_at to be included in the event?


#4

Hi @Cretcheu

All Spark cloud API endpoints return a JSON when successful. For published events, that contains the published data and some meta-data such “published_at”, “coreid” and “ttl”. Note that ttl (time-to-live) is not implemented yet and so always returns 60.

Here is the example from the doc, in this case using curl to listen for the events:

# EXAMPLE REQUEST
curl -H "Authorization: Bearer {ACCESS_TOKEN_GOES_HERE}" \
    https://api.spark.io/v1/events/motion-detected

# Will return a stream that echoes text when your event is published
event: motion-detected
data: {"data":"23:23:44","ttl":"60","published_at":"2014-05-28T19:20:34.638Z","coreid":"0123456789abcd

If you want to learn more about how to get and use these JSON fields, I recommend looking at the tutorials I wrote for publish:

and


#5

BKO,

Thank you!
Meta-data that’s the term I was looking for. I have gone through your tutorials. They were very helpful. This was the one piece I did not understand.