Skip to content

ApiConnection

QuantConnect.Api.ApiConnection

ApiConnection(user_id: int, token: str)
ApiConnection(
    user_id: int,
    token: str,
    base_url: str = None,
    default_headers: Dictionary[str, str] = None,
    timeout: int = 0,
)

Bases: Object, IDisposable

API Connection and Hash Manager

Create a new Api Connection Class.

Parameters:

Name Type Description Default
user_id int

User Id number from QuantConnect.com account. Found at www.quantconnect.com/account

required
token str

Access token for the QuantConnect account. Found at www.quantconnect.com/account

required
base_url Optional[str]

The client's base address

None
default_headers Optional[Dictionary[str, str]]

Default headers for the client

None
timeout Optional[int]

The client timeout in seconds

0

client

client: Any

Authorized client to use for requests.

RestSharp is deprecated and will be removed in a future release. Please use the SetClient method or the request methods that take an HttpRequestMessage

connected

connected: bool

Return true if connected successfully.

dispose

dispose() -> None

Disposes of the HTTP client

set_client

set_client(
    base_url: str,
    default_headers: Dictionary[str, str] = None,
    timeout: int = 0,
) -> None

Overrides the current client

Parameters:

Name Type Description Default
base_url str

The client's base address

required
default_headers Dictionary[str, str]

Default headers for the client

None
timeout int

The client timeout in seconds

0