# Where does this MyDeviceAPI class in the Discovery example come from?

**URL:** <https://community.homey.app/t/where-does-this-mydeviceapi-class-in-the-discovery-example-come-from/91283>\
**Category:** Developers\
**Created:** [October 8, 2023, 12:48pm UTC](https://community.homey.app/t/where-does-this-mydeviceapi-class-in-the-discovery-example-come-from/91283 "2023-10-08T12:48:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Vestjens](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/patrick_vestjens/32/67696_2.png) [@Patrick\_Vestjens](https://community.homey.app/u/Patrick_Vestjens)\
**Post date:** [October 8, 2023, 12:48pm UTC](https://community.homey.app/t/where-does-this-mydeviceapi-class-in-the-discovery-example-come-from/91283/1 "2023-10-08T12:48:14Z")

</div>

I’m making my first steps in Homey device development and followed the Getting started tutorial. All was going fine until I used the device.js code snippet for onDiscoveryAvailable on the Discovery page ([Discovery - Homey Apps SDK](https://apps.developer.homey.app/wireless/wi-fi/discovery)):

async onDiscoveryAvailable(discoveryResult) {  
// This method will be executed once when the device has been found (onDiscoveryResult returned true)  
this.api = new MyDeviceAPI(discoveryResult.address);  
await this.api.connect(); // When this throws, the device will become unavailable.  
}

During execution, I get a reference error on the line instantiating a new MyDeviceAPI object. Where should this MyDeviceAPI class be defined and implemented? I can’t find it in the code generated by “homey app create”.

Best regards,  
Patrick.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [October 8, 2023, 12:50pm UTC](https://community.homey.app/t/where-does-this-mydeviceapi-class-in-the-discovery-example-come-from/91283/2 "2023-10-08T12:50:59Z")

</div>

It’s just an example on how you could pass the discovery result to a custom class that implements access to your device’s API. In other words, “INSERT YOUR OWN DEVICE IMPLEMENTATION HERE”.

---

<div class="post-metadata">

**Author:** ![Patrick\_Vestjens](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/patrick_vestjens/32/67696_2.png) [@Patrick\_Vestjens](https://community.homey.app/u/Patrick_Vestjens)\
**Post date:** [October 8, 2023, 2:20pm UTC](https://community.homey.app/t/where-does-this-mydeviceapi-class-in-the-discovery-example-come-from/91283/3 "2023-10-08T14:20:38Z")

</div>

Ok, thanks. Then I’ll just remove all the api stuff.
