I need to setup Galaxy on a server for NGS analysis. The server is pretty closed and internal and I there is no HTTP server. I don't have root permissions as well. I'm going to control the Galaxy instance through API. But the problem is that I cannot generate an API key. How can I do it through the API, without the web-interface?

You can set `master_api_key` in your Galaxy's `universe_wsgi.ini` file to have an admin key capable of using some of the API without being tied to a particular user. Some API endpoints will not work without a real user however, so I would then use this key to generate a user and then an API key for this user (or just the API key a user already exists). To create a user you can use a `POST` to `/api/users` with a `username`, `password`, and `email` in the payload. You can POST to /api/users/{encoded_user_id}/api_key with the created user's encoded id to get an API key for that user.

bioblend and blend4j - the Python and Java libraries for targeting the Galaxy API - already have utility methods for performing these actions against the Galaxy API and I would recommend using these. Also, if you want to create users and API keys in batch without setting a `master_api_key` there is a seed script that can by adapted that targets the Galaxy database and can do this. This is how the Galaxy Bootstrap creates Galaxy instances with pre-populated users and API keys.