new Client(options)
Constructs a new Fantasy Client. Each client is tied to a single account.
For most applications, you will only need to instantiate one client.
Parameters:
Name | Type | Description |
---|---|---|
options |
ClientOptions | The optional client settings |
Members
-
<constant> API_URL :String
-
The base url for the API
Type:
- String
-
circuits :Map.<String, Circuit>
-
The circuits cache, keyed by the short name (short_name)
Type:
- Map.<String, Circuit>
-
constructors :Map.<String, Constructor>
-
The constructor cache, keyed by team name
Type:
- Map.<String, Constructor>
-
currentGrandPrix :GrandPrix
-
The current Grand Prix for this week
Type:
-
debug :Boolean
-
Whether to enable debug mode
Type:
- Boolean
-
drivers :Map.<String, Driver>
-
The driver cache, keyed by last name
Type:
- Map.<String, Driver>
-
grandsPrix :Map.<String, GrandPrix>
-
The Grand Prix cache, keyed by the short name (short_name)
Type:
- Map.<String, GrandPrix>
-
players :Map.<T, Player>
-
The Fantasy F1 player cache
Type:
- Map.<T, Player>
-
races :Map.<String, Race>
-
The races cache
Type:
- Map.<String, Race>
Methods
-
<private> _request(options)
-
Makes an HTTP request to an endpoint
Parameters:
Name Type Description options
RequestOptions Extra options for the HTTP request -
fetchDriversAndConstructors(forceUpdate)
-
Fetch all drivers and constructors and add them to cache
Parameters:
Name Type Description forceUpdate
Boolean Whether to ignore the cache and update the list directly Returns:
Map -
init()
-
Fetches the initial data
Returns:
- Type
- Promise.<Client>
-
login(username, password)
-
Parameters:
Name Type Description username
String Account username to the F1 Fantasy API password
String Account password to the F1 Fantasy API