Starting a new thread about REST API so that I can work out some issues and possibly help others on their way going forward.
Here is some known info so far:
First, register your application at https://www.lfs.net/account/api .
You can then request a Bearer token with your client ID and client secret at id.lfs.net. Quick example:
With the obtained Bearer token, you can use our new API at https://api.lfs.net . Quick example:
That gives you a list of all vehicle mods. The schema of a VehicleModSummary object:
You can also get more detailed by performing a GET /vehiclemod/{id} which will return:
Here is some known info so far:
First, register your application at https://www.lfs.net/account/api .
You can then request a Bearer token with your client ID and client secret at id.lfs.net. Quick example:
// Request a Bearer token by using the client_credentials grant type.
// This requires client_id and client_secret.
// One can simply fetch that by POSTing those values. See below for example.
$accessTokenUrl = 'https://id.lfs.net/oauth2/access_token';
$accessTokenPost = [
'grant_type' => 'client_credentials',
'client_id' => 'dfffniwufhnfr823nhr',
'client_secret' => '4n8rrrn3ycnf48ycf8ny4r',
];
$context = stream_context_create([
'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => http_build_query($accessTokenPost),
'ignore_errors' => true,
]
]);
$result = file_get_contents($accessTokenUrl, false, $context);
if ($result)
{
$json = json_decode($result);
print_r($json);
}
else
{
var_dump($http_response_header);
var_dump($result);
}
With the obtained Bearer token, you can use our new API at https://api.lfs.net . Quick example:
$bearerToken = 'abcdefetc';
$apiUrl = 'https://api.lfs.net/vehiclemod';
$opts = array('http' =>
array(
'method' => 'GET',
'header' => 'Authorization: Bearer '.$bearerToken,
)
);
$result = file_get_contents(
$apiUrl,
false,
stream_context_create($opts)
);
if ($result)
{
header('Content-Type: application/json');
echo $result;
}
else
{
var_dump($http_response_header);
var_dump($result);
}
That gives you a list of all vehicle mods. The schema of a VehicleModSummary object:
{
"data": {
"id": string // Vehicle Mod identifier. AKA Skin ID, in HEX format
"name": string // Vehicle Mod name
"descriptionShort": string // Short description
"description": string // Description
"userId": int // Uploader user ID
"userName": string // Uploader user Name
"wip": boolean // Work In Progress
"publishedAt": int // Unixtimestamp of publish date
"numDownloads": int // Number of downloads
"curUsage": int // Number of racers using this mod online right now
"rating": int // Rating, from 0 - 5
"numRatings": int // Number of people who rated
"version": int // Vehicle Mod Version
"lastDownloadedAt": int // Unixtimestamp of last download date
"class": int // Vehicle class
"ev": boolean // Electric Vehicle if true
}
}
}
"class":
0: Object
1: Touring car
2: Saloon car
3: Buggy
4: Formula
5: GT
6: Kart
7: Bike
8: Van
9: Truck
10: Formula 1
11: Formula SAE
You can also get more detailed by performing a GET /vehiclemod/{id} which will return:
{
"data": {
"id": string // Vehicle Mod identifier. AKA Skin ID, in HEX format
"name": string // Vehicle Mod name
"descriptionShort": string // Short description
"description": string // Description
"userId": int // Uploader user ID
"userName": string // Uploader user Name
"wip": boolean // Work In Progress
"publishedAt": int // Unixtimestamp of publish date
"numDownloads": int // Number of downloads
"curUsage": int // Number of racers using this mod online right now
"rating": int // Rating, from 0 - 5
"numRatings": int // Number of people who rated
"version": int // Vehicle Mod Version
"lastDownloadedAt": int // Unixtimestamp of last download date
"class": int // Vehicle class
"ev": boolean // Electric Vehicle if true
"vehicle": {
"iceCc": int // ICE cc
"iceNumCylinders": int // ICE number of cylinders
"iceLayout": int // ICE engine layout
"evRedLine": float // EV redline
"drive": int // Drive
"shiftType": int // Shift type
"power": float // Power in kW
"maxPowerRpm": int // Max power at RPM
"torque": float // Torque in Nm
"maxTorqueRpm": int // Max torque at RPM
"mass": float // Total mass of vehicle in kg
"bhp": float // BHP
"powerWightRatio": float // Power to weight ratio
"bhpTon": float // BHP per ton
"fuelTankSize": float // Fuel tank size. If "ev" = true, its unit is kWh, otherwise litres
}
}
}
"class":
0: Object
1: Touring car
2: Saloon car
3: Buggy
4: Formula
5: GT
6: Kart
7: Bike
8: Van
9: Truck
10: Formula 1
11: Formula SAE
"iceLayout":
0: inline
1: flat
2: V
"drive":
0: None
1: Rear wheel drive
2: Front wheel drive
3: All wheel drive
"shiftType":
0: None
1: H-pattern gearbox
2: Motorbike
3: Sequential
4: Sequential with ignition cut
5: Paddle
6: Electric motor
7: Centrifugal clutch