class, default_timeout=(10, 60), base_url=None)[source]

Subclass of requests.Session to handle requets to the SolarForecastArbiter API. The Session provides connection pooling, automatic retries for certain types of requets, default timeouts, and a default base url. Responses are converted into the appropriate class from or a pandas object.

  • access_token (string or HiddenToken) – The base64 encoded Bearer token to authenticate with the API
  • default_timeout (float or tuple, optional) – A default timeout to add to all requests. If a tuple, the first element is the connection timeout and the second is the read timeout. Default is 10 seconds for connection and 60 seconds to read from the server.
  • base_url (string) – URL to use as the base for endpoints to APISession
__init__(access_token, default_timeout=(10, 60), base_url=None)[source]

Initialize self. See help(type(self)) for accurate signature.


__init__(access_token[, default_timeout, …]) Initialize self.
close() Closes all adapters and as such the session
create_forecast(forecast) Create a new forecast in the API with the given Forecast model
create_observation(observation) Create a new observation in the API with the given Observation model
create_site(site) Create a new site in the API with the given Site model
delete(url, **kwargs) Sends a DELETE request.
get(url, **kwargs) Sends a GET request.
get_adapter(url) Returns the appropriate connection adapter for the given URL.
get_forecast(forecast_id) Get Forecast metadata from the API for the given forecast_id
get_forecast_values(forecast_id, start, end) Get forecast values from start to end for forecast_id
get_observation(observation_id) Get the metadata from the API for the a given observation_id in an Observation object.
get_observation_values(observation_id, …) Get observation values from start to end for observation_id from the API
get_redirect_target(resp) Receives a Response.
get_site(site_id) Retrieve site metadata for site_id from the API and process into the proper model.
head(url, **kwargs) Sends a HEAD request.
list_forecasts() List all Forecasts a user has access to.
list_observations() List the observations a user has access to.
list_sites() List all the sites available to a user.
merge_environment_settings(url, proxies, …) Check the environment and merge it with some settings.
mount(prefix, adapter) Registers a connection adapter to a prefix.
options(url, **kwargs) Sends a OPTIONS request.
patch(url[, data]) Sends a PATCH request.
post(url[, data, json]) Sends a POST request.
post_forecast_values(forecast_id, …) Upload the given forecast values to the appropriate forecast_id of the API
post_observation_values(observation_id, …) Upload the given observation values to the appropriate observation_id of the API.
prepare_request(request) Constructs a PreparedRequest for transmission and returns it.
put(url[, data]) Sends a PUT request.
rebuild_auth(prepared_request, response) When being redirected we may want to strip authentication from the request to avoid leaking credentials.
rebuild_method(prepared_request, response) When being redirected we may want to change the method of the request based on certain specs or browser behavior.
rebuild_proxies(prepared_request, proxies) This method re-evaluates the proxy configuration by considering the environment variables.
request(method, url, *args, **kwargs) Modify the default Session.request to add in the default timeout and make requests relative to the base_url.
resolve_redirects(resp, req[, stream, …]) Receives a Response.
send(request, **kwargs) Send a given PreparedRequest.
should_strip_auth(old_url, new_url) Decide whether Authorization header should be removed when redirecting