# Importing python library - the wrong way?

**URL:** <https://forum.inductiveautomation.com/t/importing-python-library-the-wrong-way/40527>\
**Category:** Maker\
**Created:** [November 11, 2020, 1:02pm UTC](https://forum.inductiveautomation.com/t/importing-python-library-the-wrong-way/40527 "2020-11-11T13:02:07Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [November 11, 2020, 6:27pm UTC](https://forum.inductiveautomation.com/t/importing-python-library-the-wrong-way/40527/5 "2020-11-11T18:27:35Z")

</div>

The last commit in the Python registry you linked is titled ‘drop Python 2 support’, so you might not have much luck.  
But, really, it looks like the API is pretty simple to wrap. Try this out:

```python
class AmbientWeatherClient(object):
	def __init__ (self, applicationKey, apiKey):
		self.baseUrl = "https://api.ambientweather.net/v1/"
		self.authorization = {
			"applicationKey": applicationKey,
			"apiKey": apiKey
		}	
		self.client = system.net.httpClient()
		
	def call(self, endpoint, **kwargs):
		kwargs.update(self.authorization)
		response = self.client.get(self.baseUrl + endpoint, params=kwargs)
		return response.json

	def get_devices(self):
		# https://api.ambientweather.net/v1/devices?applicationKey=&apiKey=
		return self.call("devices")

	def get_data(self, macAddress, endDate=None, limit=None):
		# https://api.ambientweather.net/v1/devices/macAddress?apiKey=&applicationKey=&endDate=&limit=288
		kwargs = {"macAddress": macAddress}
		if endDate is not None:
			kwargs["endDate"] = endDate
		if limit is not None:
			kwargs["limit"] = limit
		return self.call("devices", **kwargs)
		
client = AmbientWeatherClient("yourApplicationKey", "yourApiKey")

print client.get_devices()

print client.get_data("yourDeviceMacAddress")

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/importing-python-library-the-wrong-way/40527)._
