Skip to main content

API - Asset Last Trade

code repository

To help you get started with the iWantFuel API quickly and confidently, we’ve created plug-and-play code samples across all major programming languages and libraries.

Whether you're building in PHP, Python, JavaScript, Java, or beyond, these examples are designed to simplify your development process.

At iWantFuel, our mission is to help you unlock the full power of our platform—while keeping integration seamless, secure, and developer-friendly.

Available Code Samples Include:

  • C# – HttpClient, RestSharp
  • cURL
  • Dart – dio, http
  • Go – Native
  • HTTP (raw)
  • Java – OkHttp, Unirest
  • JavaScript – Fetch, jQuery, XHR
  • Kotlin – OkHttp
  • C – libcurl
  • Node.js – Axios, Native, Request, Unirest
  • Objective-C – NSURLSession
  • OCaml – Cohttp
  • PHP – cURL, Guzzle, HTTP_Request2, pecl_http
  • PowerShell – Invoke-RestMethod
  • Python – http.client, Requests
  • R – httr, RCurl
  • Ruby – Net::HTTP, reqwest, Httpie
  • Shell – wget
  • Swift – URLSession

Start integrating with confidence—and bring seamless driver management to your platform today.

Sample Response

{
    "id": 26933,
    "date_time": "2025-05-08 11:11:33",
    "site_name": "Puma Stellenbosch",
    "Zone": "1A",
    "ref_no": "IWF3-KU51JND6-iFill",
    "product": "Diesel 50 ppm",
    "vehicle": "CFM28000",
    "Vehicle_Full_Name": "2012 CFM28000 - Nissan Navara",
    "ODO": "253000",
    "driver": "Andrew Heath",
    "fill_type": "Fill-Up",
    "collected_litres": "35.00",
    "total_amount": "672.35",
    "price_pl": "19.21",
    "currency": "ZAR",
    "Country": "Republic of South Africa",
    "juser": "535",
    "COR_Ref_no": "COR3-ADXR72F9-537",
    "QA_Status": "QA Pass",
    "Product_Metric": "Litres",
    "secnd_amount": "-672.35"
}

C# - HttpClient

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://www.iwantfuel.tech/api/Get_Last_Trade.php");
request.Headers.Add("X-API-KEY", "Enter API Key Here");
request.Headers.Add("X-SECRET-KEY", "Enter Secret Key Here");
var content = new StringContent("{\n  \"Asset_Registration_No\": \"ABC123GP\"\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

C# - RestSharp

var options = new RestClientOptions("https://www.iwantfuel.tech")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/api/Get_Last_Trade.php", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-API-KEY", "Enter API Key Here");
request.AddHeader("X-SECRET-KEY", "Enter Secret Key Here");
var body = @"{" + "\n" +
@"  ""Asset_Registration_No"": ""ABC123GP""" + "\n" +
@"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);

cURL

curl --location 'https://www.iwantfuel.tech/api/Get_Last_Trade.php' \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: Enter API Key Here' \
--header 'X-SECRET-KEY: Enter Secret Key Here' \
--data '{
  "Asset_Registration_No": "ABC123GP"
}'

Dart - dio

var headers = {
  'Content-Type': 'application/json',
  'X-API-KEY': 'Enter API Key Here',
  'X-SECRET-KEY': 'Enter Secret Key Here'
};
var data = json.encode({
  "Asset_Registration_No": "ABC123GP"
});
var dio = Dio();
var response = await dio.request(
  'https://www.iwantfuel.tech/api/Get_Last_Trade.php',
  options: Options(
    method: 'POST',
    headers: headers,
  ),
  data: data,
);

if (response.statusCode == 200) {
  print(json.encode(response.data));
}
else {
  print(response.statusMessage);
}

Dart - http

var headers = {
  'Content-Type': 'application/json',
  'X-API-KEY': 'Enter API Key Here',
  'X-SECRET-KEY': 'Enter Secret Key Here'
};
var request = http.Request('POST', Uri.parse('https://www.iwantfuel.tech/api/Get_Last_Trade.php'));
request.body = json.encode({
  "Asset_Registration_No": "ABC123GP"
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
  print(await response.stream.bytesToString());
}
else {
  print(response.reasonPhrase);
}

Go - Native

package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "https://www.iwantfuel.tech/api/Get_Last_Trade.php"
  method := "POST"

  payload := strings.NewReader(`{
  "Asset_Registration_No": "ABC123GP"
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("X-API-KEY", "Enter API Key Here")
  req.Header.Add("X-SECRET-KEY", "Enter Secret Key Here")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

HTTP

POST /api/Get_Last_Trade.php HTTP/1.1
Host: www.iwantfuel.tech
Content-Type: application/json
X-API-KEY: Enter API Key Here
X-SECRET-KEY: Enter Secret Key Here
Content-Length: 41

{
  "Asset_Registration_No": "ABC123GP"
}

Java - OkHttp

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"Asset_Registration_No\": \"ABC123GP\"\n}");
Request request = new Request.Builder()
  .url("https://www.iwantfuel.tech/api/Get_Last_Trade.php")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("X-API-KEY", "Enter API Key Here")
  .addHeader("X-SECRET-KEY", "Enter Secret Key Here")
  .build();
Response response = client.newCall(request).execute();

Java - Unirest

Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://www.iwantfuel.tech/api/Get_Last_Trade.php")
  .header("Content-Type", "application/json")
  .header("X-API-KEY", "Enter API Key Here")
  .header("X-SECRET-KEY", "Enter Secret Key Here")
  .body("{\n  \"Asset_Registration_No\": \"ABC123GP\"\n}")
  .asString();

JavaScript - Fetch

const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-API-KEY", "Enter API Key Here");
myHeaders.append("X-SECRET-KEY", "Enter Secret Key Here");

const raw = JSON.stringify({
  "Asset_Registration_No": "ABC123GP"
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://www.iwantfuel.tech/api/Get_Last_Trade.php", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

JavaScript - jQuery

var settings = {
  "url": "https://www.iwantfuel.tech/api/Get_Last_Trade.php",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/json",
    "X-API-KEY": "Enter API Key Here",
    "X-SECRET-KEY": "Enter Secret Key Here"
  },
  "data": JSON.stringify({
    "Asset_Registration_No": "ABC123GP"
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});

JavaScript - XHR

// WARNING: For POST requests, body is set to null by browsers.
var data = JSON.stringify({
  "Asset_Registration_No": "ABC123GP"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://www.iwantfuel.tech/api/Get_Last_Trade.php");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("X-API-KEY", "Enter API Key Here");
xhr.setRequestHeader("X-SECRET-KEY", "Enter Secret Key Here");

xhr.send(data);

Kotlin - Okhttp

val client = OkHttpClient()
val mediaType = "application/json".toMediaType()
val body = "{\n  \"Asset_Registration_No\": \"ABC123GP\"\n}".toRequestBody(mediaType)
val request = Request.Builder()
  .url("https://www.iwantfuel.tech/api/Get_Last_Trade.php")
  .post(body)
  .addHeader("Content-Type", "application/json")
  .addHeader("X-API-KEY", "Enter API Key Here")
  .addHeader("X-SECRET-KEY", "Enter Secret Key Here")
  .build()
val response = client.newCall(request).execute()

C - libcurl

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
  curl_easy_setopt(curl, CURLOPT_URL, "https://www.iwantfuel.tech/api/Get_Last_Trade.php");
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  struct curl_slist *headers = NULL;
  headers = curl_slist_append(headers, "Content-Type: application/json");
  headers = curl_slist_append(headers, "X-API-KEY: Enter API Key Here");
  headers = curl_slist_append(headers, "X-SECRET-KEY: Enter Secret Key Here");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  const char *data = "{\n  \"Asset_Registration_No\": \"ABC123GP\"\n}";
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  res = curl_easy_perform(curl);
  curl_slist_free_all(headers);
}
curl_easy_cleanup(curl);

NodeJs - Axios

const axios = require('axios');
let data = JSON.stringify({
  "Asset_Registration_No": "ABC123GP"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://www.iwantfuel.tech/api/Get_Last_Trade.php',
  headers: { 
    'Content-Type': 'application/json', 
    'X-API-KEY': 'Enter API Key Here', 
    'X-SECRET-KEY': 'Enter Secret Key Here'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

NodeJs - Native

var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'www.iwantfuel.tech',
  'path': '/api/Get_Last_Trade.php',
  'headers': {
    'Content-Type': 'application/json',
    'X-API-KEY': 'Enter API Key Here',
    'X-SECRET-KEY': 'Enter Secret Key Here'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({
  "Asset_Registration_No": "ABC123GP"
});

req.write(postData);

req.end();

NodeJs - Request

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://www.iwantfuel.tech/api/Get_Last_Trade.php',
  'headers': {
    'Content-Type': 'application/json',
    'X-API-KEY': 'Enter API Key Here',
    'X-SECRET-KEY': 'Enter Secret Key Here'
  },
  body: JSON.stringify({
    "Asset_Registration_No": "ABC123GP"
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

NodeJs - Unirest

var unirest = require('unirest');
var req = unirest('POST', 'https://www.iwantfuel.tech/api/Get_Last_Trade.php')
  .headers({
    'Content-Type': 'application/json',
    'X-API-KEY': 'Enter API Key Here',
    'X-SECRET-KEY': 'Enter Secret Key Here'
  })
  .send(JSON.stringify({
    "Asset_Registration_No": "ABC123GP"
  }))
  .end(function (res) { 
    if (res.error) throw new Error(res.error); 
    console.log(res.raw_body);
  });

Objective-C - NSURLSession

#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://www.iwantfuel.tech/api/Get_Last_Trade.php"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/json",
  @"X-API-KEY": @"Enter API Key Here",
  @"X-SECRET-KEY": @"Enter Secret Key Here"
};

[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\n  \"Asset_Registration_No\": \"ABC123GP\"\n}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

OCaml - Cohttp

open Lwt
open Cohttp
open Cohttp_lwt_unix

let postData = ref "{\n  \"Asset_Registration_No\": \"ABC123GP\"\n}";;

let reqBody = 
  let uri = Uri.of_string "https://www.iwantfuel.tech/api/Get_Last_Trade.php" in
  let headers = Header.init ()
    |> fun h -> Header.add h "Content-Type" "application/json"
    |> fun h -> Header.add h "X-API-KEY" "Enter API Key Here"
    |> fun h -> Header.add h "X-SECRET-KEY" "Enter Secret Key Here"
  in
  let body = Cohttp_lwt.Body.of_string !postData in

  Client.call ~headers ~body `POST uri >>= fun (_resp, body) ->
  body |> Cohttp_lwt.Body.to_string >|= fun body -> body

let () =
  let respBody = Lwt_main.run reqBody in
  print_endline (respBody)

PHP - cURL

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://www.iwantfuel.tech/api/Get_Last_Trade.php',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
  "Asset_Registration_No": "ABC123GP"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'X-API-KEY: Enter API Key Here',
    'X-SECRET-KEY: Enter Secret Key Here'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

PHP - Guzzle

<?php
$client = new Client();
$headers = [
  'Content-Type' => 'application/json',
  'X-API-KEY' => 'Enter API Key Here',
  'X-SECRET-KEY' => 'Enter Secret Key Here'
];
$body = '{
  "Asset_Registration_No": "ABC123GP"
}';
$request = new Request('POST', 'https://www.iwantfuel.tech/api/Get_Last_Trade.php', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();

PHP - HTTP_Request2

<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://www.iwantfuel.tech/api/Get_Last_Trade.php');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Content-Type' => 'application/json',
  'X-API-KEY' => 'Enter API Key Here',
  'X-SECRET-KEY' => 'Enter Secret Key Here'
));
$request->setBody('{\n  "Asset_Registration_No": "ABC123GP"\n}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}

PHP - pecl_http

<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://www.iwantfuel.tech/api/Get_Last_Trade.php');
$request->setRequestMethod('POST');
$body = new http\Message\Body;
$body->append('{
  "Asset_Registration_No": "ABC123GP"
}');
$request->setBody($body);
$request->setOptions(array());
$request->setHeaders(array(
  'Content-Type' => 'application/json',
  'X-API-KEY' => 'Enter API Key Here',
  'X-SECRET-KEY' => 'Enter Secret Key Here'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();

PowerShell - RestMethod

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("X-API-KEY", "Enter API Key Here")
$headers.Add("X-SECRET-KEY", "Enter Secret Key Here")

$body = @"
{
  `"Asset_Registration_No`": `"ABC123GP`"
}
"@

$response = Invoke-RestMethod 'https://www.iwantfuel.tech/api/Get_Last_Trade.php' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

Python - http.client

import http.client
import json

conn = http.client.HTTPSConnection("www.iwantfuel.tech")
payload = json.dumps({
  "Asset_Registration_No": "ABC123GP"
})
headers = {
  'Content-Type': 'application/json',
  'X-API-KEY': 'Enter API Key Here',
  'X-SECRET-KEY': 'Enter Secret Key Here'
}
conn.request("POST", "/api/Get_Last_Trade.php", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Python - Requests

import requests
import json

url = "https://www.iwantfuel.tech/api/Get_Last_Trade.php"

payload = json.dumps({
  "Asset_Registration_No": "ABC123GP"
})
headers = {
  'Content-Type': 'application/json',
  'X-API-KEY': 'Enter API Key Here',
  'X-SECRET-KEY': 'Enter Secret Key Here'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

R - httr

library(httr)

headers = c(
  'Content-Type' = 'application/json',
  'X-API-KEY' = 'Enter API Key Here',
  'X-SECRET-KEY' = 'Enter Secret Key Here'
)

body = '{
  "Asset_Registration_No": "ABC123GP"
}';

res <- VERB("POST", url = "https://www.iwantfuel.tech/api/Get_Last_Trade.php", body = body, add_headers(headers))

cat(content(res, 'text'))

R - RCurl

library(RCurl)
headers = c(
  "Content-Type" = "application/json",
  "X-API-KEY" = "Enter API Key Here",
  "X-SECRET-KEY" = "Enter Secret Key Here"
)
params = "{
  \"Asset_Registration_No\": \"ABC123GP\"
}"
res <- postForm("https://www.iwantfuel.tech/api/Get_Last_Trade.php", .opts=list(postfields = params, httpheader = headers, followlocation = TRUE), style = "httppost")
cat(res)

Ruby - Net::HTTP

require "uri"
require "json"
require "net/http"

url = URI("https://www.iwantfuel.tech/api/Get_Last_Trade.php")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["X-API-KEY"] = "Enter API Key Here"
request["X-SECRET-KEY"] = "Enter Secret Key Here"
request.body = JSON.dump({
  "Asset_Registration_No": "ABC123GP"
})

response = https.request(request)
puts response.read_body

Ruby - reqwest

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::builder()
        .build()?;

    let mut headers = reqwest::header::HeaderMap::new();
    headers.insert("Content-Type", "application/json".parse()?);
    headers.insert("X-API-KEY", "Enter API Key Here".parse()?);
    headers.insert("X-SECRET-KEY", "Enter Secret Key Here".parse()?);

    let data = r#"{
    "Asset_Registration_No": "ABC123GP"
}"#;

    let json: serde_json::Value = serde_json::from_str(&data)?;

    let request = client.request(reqwest::Method::POST, "https://www.iwantfuel.tech/api/Get_Last_Trade.php")
        .headers(headers)
        .json(&json);

    let response = request.send().await?;
    let body = response.text().await?;

    println!("{}", body);

    Ok(())
}

Ruby - Httpie

printf '{
  "Asset_Registration_No": "ABC123GP"
}'| http  --follow --timeout 3600 POST 'https://www.iwantfuel.tech/api/Get_Last_Trade.php' \
 Content-Type:'application/json' \
 X-API-KEY:'Enter API Key Here' \
 X-SECRET-KEY:'Enter Secret Key Here'

Shell - wget

wget --no-check-certificate --quiet \
  --method POST \
  --timeout=0 \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: Enter API Key Here' \
  --header 'X-SECRET-KEY: Enter Secret Key Here' \
  --body-data '{
  "Asset_Registration_No": "ABC123GP"
}' \
   'https://www.iwantfuel.tech/api/Get_Last_Trade.php'

Swift - URLSession

let parameters = "{\n  \"Asset_Registration_No\": \"ABC123GP\"\n}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "https://www.iwantfuel.tech/api/Get_Last_Trade.php")!,timeoutInterval: Double.infinity)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("Enter API Key Here", forHTTPHeaderField: "X-API-KEY")
request.addValue("Enter Secret Key Here", forHTTPHeaderField: "X-SECRET-KEY")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()