I study REST API and I found out that communication with GitHub API should start with root request which returns links to most essential resources:
https://docs.github.com/en/rest/meta/meta?apiVersion=2022-11-28
This practice aligns with HATEOAS principle which gives client possibility to send request without hard coding or modification of URI's.
But here is the thing:
https://api.github.com/search/users?q={query}{&page,per_page,sort,order}
I don't understand how can I fetch it without modification? HATEOAS trying to make client-server communication loosely coupled. Am I missing something?
Best variant that I found:
const baseURI = "https://api.github.com/search/issues?q={query}";
const searchQuery = 'your-search-query';
const endpoint = baseURI.replace('{query}', encodeURIComponent(searchQuery));
fetch(endpoint).then(res => res.json());
But as a client I definitely have to know exact URI to change it in the appropriate way. And if I need to use this request in multiple places I have to repeat this process. Or change all links that I got from the root request. But the URI template could be more complicated, so this is not a variant.