About the input api.. Does it accept http post?

So this isn’t clear to me, when i look at the input api help page all samples i’m seeing mostly seem to use http get statements with all data passed in with the parameters.

Since i’m currently using this system for emoncms_history component with http get{sensor1:200,sensor2:400,sensor3:4.5} i was wondering… There are probably limits on how long the url can be, i think this mostly depends on software used as well as webservers… I’ve read somewhere on stackoverflow that apache only seemed to like up until 4000 bytes (/ characters ?) but i was not sure how accurate it was. As i’m currently sending all the data in one http get the url can, depending on the number of data being send from home assistant, become quite long and i’m affraid of hitting some limit. I’m currently sending the entityid which basically is the name of the component and its value using this system so the url quickly grows depending on the component’s name length ( entity_id) and the number of components to send data for

So i’d like to know does http post also work ? if so what should i actually send ? i should probably post to but what’s the data to be posted then ?

Also i’m guessing http post can send a lot more data compared to http get so if it supports http post and i’m switching to http post instead of http get i would probably be on the safe side when sending large amounts of data due to a high number of sensors / components selected to send it’s data to emoncms right ? It’s not that it will send tons of data but as i don’t know about the limits of http get i’d like to be on the safe side and use http post if that allaws for more data

I thought someone would have a quick answer for this but it seems not … so i dug in the sources… The answer is YES it supports http post but it is not documented for some reason on the input api page and it doesn’t accept every parameter in the post data.

what i saw in the sources is that you can specify{sensor1:200,sensor2:400,sensor3:4.5}
which is exacltly the same as{sensor1:200,sensor2:400,sensor3:4.5}
but the important part is that the data value is also requested using $_POST it’s the only parameter in this case that can be “posted” (if you don’t include the apikey parameter as this is mentioned it can be posted but i did not test it)

see these lines here emoncms/input_controller.php at master · emoncms/emoncms · GitHub

if you see that code you’ll notice that this works also:{sensor1:200,sensor2:400,sensor3:4.5}

so i did a curl test with http post like so :

curl --data "data={sensor1:200,sensor2:400,sensor3:4.5}" ""

and this worked !

Now the BIG Question why isn’t this documented on Emoncms - site api ??? Especially the data parameter that can be used in http post

the second question will the http post using the data parameter keep functioning in the future, the reason i’m asking is because it isn’t documented (or at least i could not see it). Is it perhaps forgotten to update the documentation about this ?

I want to use http post + that data parameter but i need to be sure it won’t be removed all of a sudden … perhaps the input api documentation needs to be updated to include the part about the data parameter especially that you can http post using it ? (since all examples on the input api page using the links are actually http GET and not http POST)

it’s also weird on the input api page to mention the apikey can be http posted but nothing else about the data parameter that can be used to http post, actually the api key is the only mention of being able to http post …

edit: just tested against emoncms.org and it works there also

There is nothing in the pipeline as far as I know to retire this facility.
If you wish to improve the documentation by adding these options, please do so. I’m sure others would find it useful.


i’ll see if can change that api pages to add that information in a pr, perhaps this weekend. I’d have to look up the other possible http post values for bulk for example & test out the post part of the apikey as well. I’m not a native english speaker so i hope i won’t make too many mistakes… I’ll see what i can do

i created a pull request to update the input api documentation with http post section using curl examples to post the data

Thanks Heaps for this, it certainly helped me understand the API a bit more. Is there any way to use curl and the data format to post more than one data set. I know that the bulk api has quantity limitations. I have a few thousands csv data points and it would be good to automate with curl rather than posting each one individually.

Cheers Paul