Connecting to Server

To access remotely the data stored on OpenWeather managed DEKER™ server infrastructure, you need to use server adapters.

It is an original OpenWeather plugin, based on httpx with HTTP 2.0 support, that allows your local client to communicate with remote OpenWeather public server instances of DEKER™.

DEKER™ will automatically find and initialize this plugin if it is installed in current environment.

Attention

You must install deker-server-adapters package , for details refer to the Installation page

Usage

To use server version, you have to initialize DEKER™ Client with an uri which contains http/https scheme.

from deker import Client
client = Client("http://{url-to-deker-server}") # As simple as that

And now the client will communicate with DEKER™ server.

If authentication is enabled on the DEKER™ server, you can provide credentials by adding it to the url like this:

from deker import client
client = Client("https://{username}:{password}@{url-to-deker-server}")

Configuration

Server adapters use httpx client under the hood. You can configure its behaviour by passing keyword arguments to the httpx_conf parameter of the DEKER™ Client:

import httpx
from deker import Client

limits = httpx.Limits(max_keepalive_connections=5, max_connections=10)
client = Client(
    "http://{url-to-deker-server}",
    httpx_conf={'http2': False, 'timeout': 10, 'limits': limits}
)

By default, adapters’ httpx client has following settings:

Key

Type

Default Value

verify

bool

True

http2

bool

False

timeout

Optional[int, float]

None

The full list of httpx configuration parameters you can find at the official website.

Errors

exception DekerServerError(response: Response, message: str)

Bases: DekerBaseApplicationError

Server error, which is raised on any non-specific occasion (like 5xx status from server)

Parameters
  • response – Httpx Response

  • message – Message of exception

exception DekerTimeoutServer

Bases: DekerServerError

This exception is raised on any timeout (Httpx’s Timeout exception or 504 status)

exception DekerBaseRateLimitError(message: str, limit: Optional[int], remaining: Optional[int], reset: Optional[int])

Bases: DekerBaseApplicationError

Parameters
  • message – Exception message

  • limit – Requests per second limit for the user

  • remaining – How many requests per second are left

  • reset – When limits will be reset

exception DekerRateLimitError

Bases: DekerBaseRateLimitError

If user’s rate limit is exceeded

exception DekerDataPointsLimitError

Bases: DekerBaseRateLimitError

If requested subset exceeds quota