Files
plex-sdk-docs/content/pages/01-reference/python/server_options/_snippet.mdx

76 lines
1.8 KiB
Plaintext

{/* Start Python Server Options */}
### Select Server by Index
You can override the default server globally by passing a server index to the `server_idx: int` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
#### Example
```python
import plex_api
s = plex_api.PlexAPI(
server_idx=0,
access_token="<YOUR_API_KEY_HERE>",
x_plex_client_identifier='Postman',
)
res = s.server.get_server_capabilities()
if res.object is not None:
# handle response
pass
```
#### Variables
Some of the server options above contain variables. If you want to set the values of those variables, the following optional parameters are available when initializing the SDK client instance:
* `protocol: models.ServerProtocol`
* `ip: str`
* `port: str`
### Override Server URL Per-Client
The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
```python
import plex_api
s = plex_api.PlexAPI(
server_url="{protocol}://{ip}:{port}",
access_token="<YOUR_API_KEY_HERE>",
x_plex_client_identifier='Postman',
)
res = s.server.get_server_capabilities()
if res.object is not None:
# handle response
pass
```
### Override Server URL Per-Operation
The server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:
```python
import plex_api
s = plex_api.PlexAPI(
x_plex_client_identifier='Postman',
)
res = s.plex.get_pin(strong=False, x_plex_client_identifier='Postman', server_url="https://plex.tv/api/v2")
if res.object is not None:
# handle response
pass
```
{/* End Python Server Options */}