I want to create a sort of private Q&A site to allow university students of the same courses to communicate. Is it possible by using the Stack Exchange API?
No, the API only allows you to connect to existing Stack Exchange sites, and Stack Exchange no longer sells public-facing sites. Stack Overflow Enterprise is available for internal use, but it is really meant for larger organizations only.
It looks like you want one of the clones listed on Meta.
Since it's not clear which, if any, of those clones offer an API, there is another approach...
If you submit your site through the Area 51 proposal process and it goes to beta, then you can access the new site through the API. It won't be private, but you could potentially get a lot more people helping as well.
Yes, you can now use Stack Overflow for Teams to create a private Q&A site with all the Stack-Overflowy goodness. (Plus an "ask" pinging feature suitable for closed/private organizations.)
See the Teams landing page and note that they do have an educational discount:
Do you offer special pricing to nonprofit organizations and educational institutions?
Yes, contact us to learn about our special pricing structure.
For more information see the stack-overflow-for-teams tag on Meta Stack Overflow.
Teams do have API support, although it is read-only at the moment.