Currently it is possible to link chapters to books using the API, it is a mandatory option. It isn't yet possible to link books to shelves using the API.
Hi @Legoracers,
You should be able to use the Shelves update request (PUT) to link a shelf to books.
From the docs:

Let me know if you experience any trouble using that. Note that it does mention that it will overwrite existing book assignments so, depending on what you're doing, you may need to read the shelf first to get its current assignments.
Thank you for the response! I will try it shortly and will let you know.
It worked, thanks!
Most helpful comment
It worked, thanks!