Most programmers who write applications for X will use third party toolkits.
If you are interested in writing an application that uses X primitives directly without the use of a toolkit, you can use the Xlib interface, painful though it is; or the xcb interface, which is missing many of Xlib’s warts, but still does not provide any of the widgets, internationalization, or accessibility support of a modern toolkit. The X New Developer’s Guide includes a chapter on Xlib and XCB that explains the different design approaches.
The documentation for the Xlib interface can be found at:
The documentation for the xcb interfaces can be found at:
O’Reilly & Associates have also made freely available online some of their classic X programming manuals. These are a bit older, dating from the X11R3, R4, or R5 eras, and the toolkit ones cover Xt-based toolkits which are no longer in widespread use for new applications, but much of the Xlib documentation still applies, it just doesn’t cover all the new additions:
Programmers writing applications that will use OpenGL can learn more in the free online book Learning Modern 3D Graphics Programming.