Skip to content

Commit 34153ba

Browse files
readme update
1 parent c22f0dd commit 34153ba

File tree

2 files changed

+58
-23
lines changed

2 files changed

+58
-23
lines changed

README.md

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ The `SatisfactoryAPI` class is the main entry point for interacting with the ser
3535
from satisfactory_api_client import SatisfactoryAPI
3636

3737
# Initialize the API client
38-
api = SatisfactoryAPI(host='your-server-ip', port=7777, auth_token='your-auth-token')
38+
api = SatisfactoryAPI(host='your-server-ip')
39+
40+
# You can also specify a custom port
41+
api = SatisfactoryAPI(host='your-server-ip', port=15000)
42+
43+
# You can also give a token directly without login
44+
api = SatisfactoryAPI(host='your-server-ip', auth_token='your-token')
3945
```
4046

4147
### Login
@@ -52,15 +58,35 @@ response = api.passwordless_login(MinimumPrivilegeLevel.ADMIN)
5258
response = api.password_login(MinimumPrivilegeLevel.ADMIN, password='your-admin-password')
5359
```
5460

61+
#### Minimum Privilege Levels
62+
63+
The `MinimumPrivilegeLevel` enum is used to specify the type of token you want to obtain. The following levels are available:
64+
- NOT_AUTHENTICATED
65+
- CLIENT
66+
- ADMINISTRATOR
67+
- INITIAL_ADMIN
68+
- API_TOKEN
69+
70+
5571
### Health Check
5672

57-
To verify that the server is running and responsive, you can perform a health check:
73+
To verify that the server is running and responsive, you can perform a health check. This will return the server's current state. You dont need a token to perform a health check.
5874

5975
```python
6076
response = api.health_check()
6177
print(response.data)
6278
```
6379

80+
### Querying server state
81+
82+
You can query the server's current state. This return information about the server and the current game session.
83+
84+
```python
85+
# Get server state
86+
response = api.query_server_state()
87+
print(response.data)
88+
```
89+
6490
### Server Options
6591

6692
You can query the server's current options and apply new ones:
@@ -93,7 +119,7 @@ response = api.apply_advanced_game_settings(new_settings)
93119

94120
### Managing Game Sessions
95121

96-
You can create, load, save, and delete game sessions.
122+
You can create, load, save, and delete game sessions. The `NewGameData` class is used to specify the parameters for creating a new game.
97123

98124
```python
99125
from satisfactory_api_client.data import NewGameData
@@ -114,7 +140,7 @@ response = api.delete_save_file("MySaveGame")
114140

115141
### Running Commands and Managing the Server
116142

117-
You can run commands on the server or shut it down:
143+
You can run commands on the server or shut it down using the API. The `run_command` method is used to execute a server command. The `shutdown` method is used to shut down the server.
118144

119145
```python
120146
# Run a server command
@@ -128,36 +154,37 @@ response = api.shutdown()
128154

129155
### Authentication
130156

131-
- `passwordless_login(minimum_privilege_level: MinimumPrivilegeLevel)`: Log in without a password.
132-
- `password_login(minimum_privilege_level: MinimumPrivilegeLevel, password: str)`: Log in using a password.
157+
- `passwordless_login(minimum_privilege_level: MinimumPrivilegeLevel)`: Log in without a password to obtain a token that is automatically saved.
158+
- `password_login(minimum_privilege_level: MinimumPrivilegeLevel, password: str)`: Log in using a password to obtain a token that is automatically saved.
133159

134160
### Server Management
135161

136-
- `health_check(client_custom_data: str = '')`: Perform a health check on the server.
137-
- `shutdown()`: Shut down the server.
162+
- `health_check(client_custom_data: str = '')`: Perform a health check on the server. This will return the server's current state.
163+
- `query_server_state()`: Query the server's current state. This includes information about the server and the current game session.
164+
- `shutdown()`: Shut down the server. This will stop the server process.
138165

139166
### Game Management
140167

141-
- `create_new_game(game_data: NewGameData)`: Create a new game session.
142-
- `load_game(save_name: str, enable_advanced_game_settings: bool = False)`: Load a saved game.
143-
- `save_game(save_name: str)`: Save the current game session.
144-
- `delete_save_file(save_name: str)`: Delete a saved game.
145-
- `enumerate_sessions()`: List all available game sessions.
168+
- `create_new_game(game_data: NewGameData)`: Create a new game session. This will start a new game with the specified settings.
169+
- `load_game(save_name: str, enable_advanced_game_settings: bool = False)`: Load a saved game. This will load a previously saved game session.
170+
- `save_game(save_name: str)`: Save the current game session. This will save the current game state to a file.
171+
- `delete_save_file(save_name: str)`: Delete a saved game. This will delete a previously saved game session.
172+
- `enumerate_sessions()`: List all available game sessions. This will return a list of saved game sessions.
146173

147174
### Server Settings
148175

149-
- `get_server_options()`: Get current server settings.
150-
- `apply_server_options(options: dict)`: Apply new server settings.
151-
- `get_advanced_game_settings()`: Get advanced game settings.
152-
- `apply_advanced_game_settings(settings: AdvancedGameSettings)`: Apply new advanced game settings.
176+
- `get_server_options()`: Get current server settings. This includes the server name, description, and other options.
177+
- `apply_server_options(options: dict)`: Apply new server settings. This will update the server options with the specified values.
178+
- `get_advanced_game_settings()`: Get advanced game settings. This includes settings such as resource settings, enemy settings, and other advanced options.
179+
- `apply_advanced_game_settings(settings: AdvancedGameSettings)`: Apply new advanced game settings. This will update the advanced game settings with the specified values.
153180

154181
### Commands
155182

156-
- `run_command(command: str)`: Run a server command.
183+
- `run_command(command: str)`: Run a server command. This will execute the specified command on the server.
157184

158185
## Error Handling
159186

160-
Errors returned by the API will raise an `APIError` exception, which contains the error message from the server.
187+
Errors returned by the API will raise an `APIError` exception, which contains the error message from the server. You can catch and handle these errors in your code. For example:
161188

162189
```python
163190
try:
@@ -172,4 +199,12 @@ Contributions are welcome! If you find a bug or have a feature request, please c
172199

173200
## License
174201

175-
This project is licensed under the MIT License. See the LICENSE file for details.
202+
This project is licensed under the MIT License. See the LICENSE file for details.
203+
204+
## Acknowledgements
205+
206+
This package is not affiliated with or endorsed by Coffee Stain Studios. Satisfactory is a trademark of Coffee Stain Studios AB.
207+
208+
## References
209+
210+
- [Satisfactory Dedicated Server API Documentation](https://satisfactory.wiki.gg/wiki/Dedicated_servers/HTTPS_API)

satisfactory_api_client/api_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _post(self, function, data=None, files=None):
6565

6666
if response.json().get('errorCode'):
6767
raise APIError(response.json().get('errorMessage'))
68-
return response.json()
68+
return response.json().get('data')
6969

7070
def _get(self, function, data=None):
7171
"""
@@ -158,7 +158,7 @@ def passwordless_login(self, minimum_privilege_level: MinimumPrivilegeLevel) ->
158158
(e.g., incorrect password or insufficient privileges).
159159
"""
160160
response = self._post('PasswordlessLogin', {'MinimumPrivilegeLevel': minimum_privilege_level.value})
161-
self.auth_token = response['data']['authenticationToken']
161+
self.auth_token = response['authenticationToken']
162162
return Response(success=True, data=self.auth_token)
163163

164164
def password_login(self, minimum_privilege_level: MinimumPrivilegeLevel, password: str) -> Response:
@@ -187,7 +187,7 @@ def password_login(self, minimum_privilege_level: MinimumPrivilegeLevel, passwor
187187
'MinimumPrivilegeLevel': minimum_privilege_level.value,
188188
'Password': password
189189
})
190-
self.auth_token = response['data']['authenticationToken']
190+
self.auth_token = response['authenticationToken']
191191
return Response(success=True, data={'message': 'Successfully logged in, the token is now stored'})
192192

193193
def query_server_state(self):

0 commit comments

Comments
 (0)