Cumulus MX Local API: Difference between revisions

From Cumulus Wiki
Jump to navigationJump to search
(Created page with "There are two methods of calling the Cumulus MX local API (note the web tag names are case sensitive just like normal): == HTTP GET == This provides a quick and simple metho...")
 
No edit summary
Line 6: Line 6:


eg.
eg.
http://localhost:8998/api/tags/process.json?temp&hum&dew
<pre>http://localhost:8998/api/tags/process.json?temp&hum&dew</pre>
or
or
http://localhost:8998/api/tags/process.json?rc&temp&hum&dew
<pre>http://localhost:8998/api/tags/process.json?rc&temp&hum&dew</pre>


Which will return the following format string in the body...
Which will return the following format string in the body...
Line 22: Line 22:


eg.
eg.
http://localhost:8998/api/tags/process.txt
<pre>http://localhost:8998/api/tags/process.txt</pre>


With a POST body text of..
With a POST body text of..

Revision as of 10:36, 18 October 2020

There are two methods of calling the Cumulus MX local API (note the web tag names are case sensitive just like normal):

HTTP GET

This provides a quick and simple method of getting data, you just provide the web tag names in the GET URL and MX returns a simple JSON string with the tag-name:tag-value pairs. The tags are always returned with the default format. You can specify a special parameter "rc" (which must be the first URL parameter) to apply the usual remove commas format to all the tags.

eg.

http://localhost:8998/api/tags/process.json?temp&hum&dew

or

http://localhost:8998/api/tags/process.json?rc&temp&hum&dew

Which will return the following format string in the body...

{"temp":"15.8","hum":"73","dew":"10.5"}

Note, ALL values are quoted as strings as it is difficult to know which are numeric and which are not.


HTTP POST

The POST method allows you to put whatever text you like in the request body - and include any web tags plus formatting you wish. The string returned will be exactly the same text with the tags substituted with data. So you could send a simple comma separated list, or some JSON text, or XML, whatever.

eg.

http://localhost:8998/api/tags/process.txt

With a POST body text of..

<#time format="yy/MM/dd hh:mm:ss">,<#temp>,<#RecentFeelsLike d=1>

would return...

20/07/14 01:48:11,15.7,18.4

or

{
   "DateTime:"<#time format="yy/MM/dd hh:mm:ss">",
   "OutsideTemp":<#temp>,
   "FeelsLikeYest":<#RecentFeelsLike d=1>
}

would return...

{
   "DateTime:"20/07/14 01:50:56",
   "OutsideTemp":15.7,
   "FeelsLikeYest":18.4
}