https://developers.meethue.com/develop/get-started-2/ explains how to get the key to use the API. You just need to press the button on the bridge. Sth. broke for me so I wrote a loop and pressed the button frantically until one of the API calls worked:
for i in `seq 1 10`; do http -v 192.168.xxx.xxx/api devicetype="my_hue_app#script"; sleep 1; done