Have a read through here:
And here:
Edit: I see the link to the Grasshopper API broke, here’s the current documentation: