Is there a C++ API document and usage examples?


For integrating with a C++ environment, looking for C++ API documents with some usage examples. Searched for such a document, could not get it. If anyone can provide a pointer, it will be helpful.


I don’t think we provide any “C++ API,” per se. The C++ functions are all internal and thus subject to change without notice. Your best bet would be to use the C API functions listed in, since the C functions don’t tend to change much. (Python and R wrappers depend on the C functions)


Thanks for the quick response. I have looked at the c_api.h. It has very terse comments. Could you please give me an API usage document or any write up showing usage scenarios?


I agree that the C API functions are currently not well documented. For now, you should refer to the Python wrapper. In particular, pay attention to how the wrapper invokes the C API functions. They are easy to spot, since every call to C functions are wrapped with _check_call.

For instance, the following snippet invokes XGDMatrixCreateFromFile() to load a data matrix (DMatrix) from a given file.


Thank you for the help. I am looking at both python and julia integration code. However, having a C API documentation with some examples will immensely help the library integrators.


Here is a small snippet I wrote: How do I set class labels?
Hope it helps. C API documentation is currently in the backlog and has no ETA at this point.


The example is of great help. A C API document is a necessity for all developers. Please prioritize it. In the meantime, looking for all the parameters set in XGBoosterSetParam function for training and prediction. Also, model names supported by xgboost.