Maker API coding examples

I'm a newb and stuck trying to figure out how to use the API to actually use the examples given in the help file. I can code them in the url address bar and get data displayed (json). But what's the best way to implement them in my web page? I have tried a few in javascript but have had no luck. If I use fetch() I get Cors Missing Allow Origin errors. Also no luck with curl. Can anyone please post an example of how they can use this api from their own html pages?

I guess the real question is - what are you trying to achieve? And is this from within your LAN, or outside of it?

FWIW, the vast majority of users go use MakerAPI probably use it to integrate with external systems like Homebridge or Node-RED. So they aren’t using it to scrape something to display in a webpage ….

Thanks for the reply. I guess I'm just weird but I do not like any of the "dashboard" options that I've seen. I have a webserver with my EventGhost controlling my household and webpages tying into that. I'd like to use javascript to customize the appearance of that interface. I'm just weak in the comm skills to work with the api's and need some pointers. I want to be able to gather data from HE and populate my own webpage and then feed commands via the api as well. Still looking for the answer. The HE help system only goes halfway and the tech gurus figure the rest out. The lesser of us mortals have to scramble.
HE really needs to make life easier for the non-super-techs in order to achieve market success.

Have you seen the MakerAPI documentation?

As I understand it, there are two parts to your query:

  1. Receiving events from Hubitat - setup an HTTP POST endpoint on your PC (using whatever server you use). Events will be sent by Hubitat to this endpoint. The documentation has examples of what the JSON looks like.
  2. Sending commands to Hubitat. This will be done using HTTP GET commands to Hubitat. And once again, the documentation has plenty of examples of how these should be formatted.

MakerAPI will definitely send data in a documented JSON format to the HTTP POST endpoint that you setup. However, you will have to write the code on your server that processes the JSON into whatever you need it to be. SImilarly, you'll have to write the code that converts your commands into the documented HTTP GET commands that MakerAPI uses.

2 Likes

I feel like once you start stepping into the Maker API space you are entering the more technical space and there is a certain level of understanding by the person developing the system that will use the Maker API setup. For solutions like Homebridge or (up until recently) HubiVue, that requirement for understanding how to use Maker API rested with the developer of those systems, and as a user you just needed to follow their instructions for setting it up. Once you start developing something yourself, that's where you take on that responsibility.

Don't get me wrong, pointing out areas where things could be made easier is fine, even in this case, but there is a level of assumed knowledge or willingness to seek out additional knowledge.

For those less technical users, and I am thinking of people with less inclination to develop something like what you are, for them the ability to construct a dashboard in either the built in tool or using third-party options would be seen (at least by me) as the way to appeal to a mass market, the number of people wanting to hand-craft a dashboard in this way would likely be quite small in comparison. There are varying points of view about the dashboarding options, and I'm not looking to argue one way or the other on these, only to say, if any time was to be spent for the broader user-base, then I would suggest it would be more appropriate to expand these solutions.

Just my 2c... It reads as slightly argumentative, but trust me, I'm just wanting to try and put forward how others may view things. I'm just as likely to seek out a more technical solution, if only for the learning experience :slight_smile:

2 Likes

These are exactly what I want to do, I just wanted to see an example of how these posts and gets are constructed in javascript. I have a local LAN webserver from EventGhost on my HTPC and have made some nice control portals for my entertainment system. I'd like to incorporate Hubitat to that. I see in the Maker docs the commands to be used. I have entered the http://blah.blah and successfully seen the json reply. I just need to see the technique used in my code to send/receive this data. (What is the syntax to "setup an HTTP POST endpoint"?)

I admit that APIs and JSON are quite a bit above the head of the average homeowner. But I'm sure there are some that want to reach beyond that level and I'd like to see better assistance in the docs to take them (and me) to those levels. Maybe I should be going to a coding forum for these questions, I just thought there might be a few advanced coders here that could show me the way. @sburke781 is right, "there is a level of assumed knowledge or willingness to seek out additional knowledge."

I'm seeking that additional knowledge. Thanks for all your help!

2 Likes

I think you would need someone who is familiar with your http server you use to get help with that.

Again, this would be specific to the http server you use, and not something generic at the Hubitat end.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.