In order to create layers, you need the name of its generator class; check the layers Class names
Listing of layers class names
Read More list for information.
Instantiate your layer
Define the type
Change it's parameters
Place it in the Element tree
Example with a simple 2d compo layer
3D Layers
Here is an example of a simple 3d layer with a box and an additional modifier:
Shapes
Here is an example of a shape layer drawing a simple circle: