I think you mean course categories,
in this case there are number of functions in the class coursecat, you would need create() function: https://github.com/moodle/moodle/blob/MOODLE_29_STABLE/lib/coursecatlib.php#L344
Course categories is not an API, so there is no dev docs page about it. From time to time we discuss the phpdocs generation from moodle core but because of very different code style in different parts of moodle the generated phpdocs are almost impossible to navigate through.
P.S. you can see the examples of calling coursecat::create() in the unittest: https://github.com/moodle/moodle/blob/MOODLE_29_STABLE/lib/tests/coursecatlib_test.php
Just don't create courses in the real system using data generator please! I actually would not recommend creating courses from the code, better use the tool upload courses.