How to Call the Juju API?

Could somebody give me an overview of how to call the Juju controller API from my own application?

I’ve done a little looking around and it looks like the API is all websockets? Or is there a REST API. I’m just looking for a quick pointer on how it is designed and where I might go for more information. I found the schema file, but I don’t know exactly how that translates into requests I can make to the server.

The Juju API is accessed over the websocket using RPC style calls. You can take a look at the javascript lib juju docs and the examples to get up to speed quickly on interacting with the Juju API.

I’m currently in the process of rewriting the js libjuju to use TypeScript so that every call and response has detailed response and type information as well as to fix some DX issues we’ve had over the years but this version of the API is well used, stable, and the new one won’t change much wrt how the API is consumed.

You can also see how the Juju Dashboard uses this library.


Perfect, that’s exactly what I’m looking for. Thanks!

That would be very nice. :+1:

I’ve recently migrated my company’s website to full TypeScript because of the burden of manually checking types and invariants.

@hatch Is there any issue I can watch or something like that so that I can get notified when you get the TypeScript version of js-libjuju?

While not strictly about the TS conversion this updated schema issue will be closed when the conversion is complete. I’ve been running into minor issues here and there with the new Juju schema which have required updates to it from the Juju side so it’s been a bit of a hot-potatoe of late. I’m hoping to have it up, at least in beta form within the next week or so :crossed_fingers:

1 Like

Cool. It’s not super time sensitive or anything, but I’ll be watching for it to come out. :slight_smile: