# Ignition and (Docker) Portainer API. (HTTP queries)

**URL:** <https://forum.inductiveautomation.com/t/ignition-and-docker-portainer-api-http-queries/36725>\
**Category:** Ignition\
**Created:** [July 15, 2020, 1:35pm UTC](https://forum.inductiveautomation.com/t/ignition-and-docker-portainer-api-http-queries/36725 "2020-07-15T13:35:51Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 15, 2020, 3:21pm UTC](https://forum.inductiveautomation.com/t/ignition-and-docker-portainer-api-http-queries/36725/2 "2020-07-15T15:21:15Z")

</div>

Http bindings aren’t going to work well for this purpose - they’re not very good at authentication right now.  
I’d recommend [`system.net.httpClient()`](https://docs.inductiveautomation.com/display/DOC80/system.net.httpClient). You could wrap things in a class to make accessing the API a little friendlier:

```auto
class PortainerClient(object):
	def __init__ (self, baseUrl, username, password, **kwargs):
		self.baseUrl = baseUrl
		self.client = system.net.httpClient(**kwargs)
		response = self.client.post(baseUrl + "auth", data={"Username": username, "Password": password})
		self.token = response.json["jwt"]
		
	def call(self, endpoint, method="GET", **kwargs):
		headers = kwargs.get("headers", {})
		headers["Authorization"] = "Bearer {}".format(self.token)
	
		response = self.client.request(self.baseUrl + endpoint, method, headers=headers, **kwargs)
		return response.json
		
client = PortainerClient("https://docker.ia.local/api/", "admin", "password", bypass_cert_validation=True)

print client.call("endpoints/1/docker/containers/json")

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/ignition-and-docker-portainer-api-http-queries/36725)._
