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": 8,
"Fuel_Zone": "9C",
"Magisterial_district": "Alberton",
"Mag_District__Code": "8",
"Province": "Gauteng",
"Country": "South Africa",
"Geo": "(-26.2672220, 28.1219440)",
"lat": "-26.2672220",
"lng": " 28.1219440",
"zone_calc": 31,
"Diesel_500_RTL": "1890.250",
"Diesel_500_COC": "1888.550",
"Diesel_50_COC": "1891.950",
"Diesel_50_RTL": "1893.650",
"dicon": "9C.png",
"ULPLRP93_RTL": "1829.700",
"ULPLRP93_COC": "1828.000",
"ULP95_RTL": "1840.500",
"ULP95_COC": "1838.800",
"LRP95_RTL": "1840.700",
"LRP95_COC": "1839.000",
"IP_RTL": "1304.618",
"IP_COC": "1302.918",
"Diesel_50_EST_PUMP": "2122.450",
"Diesel_500_EST_PUMP": "2119.050",
"ULPLRP93_PUMP_PRICE": "2129.00",
"LRP95_PUMP_PRICE": "2140.000",
"ULP95_PUMP_PRICE": "2140.00",
"Zone_Pin": null
}
C# - HttpClient
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://www.iwantfuel.tech/api/Get_Zone_Prices.php");
request.Headers.Add("X-API-KEY", "Enter you API Here");
request.Headers.Add("X-SECRET-KEY", "Enter your Secret Key Here");
var content = new StringContent("{\n \"Fuel_Zone\": \"9C\"\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_Zone_Prices.php", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-API-KEY", "Enter you API Here");
request.AddHeader("X-SECRET-KEY", "Enter your Secret Key Here");
var body = @"{" + "\n" +
@" ""Fuel_Zone"": ""9C""" + "\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_Zone_Prices.php' \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: Enter you API Here' \
--header 'X-SECRET-KEY: Enter your Secret Key Here' \
--data '{
"Fuel_Zone": "9C"
}'
Dart - dio
var headers = {
'Content-Type': 'application/json',
'X-API-KEY': 'Enter you API Here',
'X-SECRET-KEY': 'Enter your Secret Key Here'
};
var data = json.encode({
"Fuel_Zone": "9C"
});
var dio = Dio();
var response = await dio.request(
'https://www.iwantfuel.tech/api/Get_Zone_Prices.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 you API Here',
'X-SECRET-KEY': 'Enter your Secret Key Here'
};
var request = http.Request('POST', Uri.parse('https://www.iwantfuel.tech/api/Get_Zone_Prices.php'));
request.body = json.encode({
"Fuel_Zone": "9C"
});
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_Zone_Prices.php"
method := "POST"
payload := strings.NewReader(`{
"Fuel_Zone": "9C"
}`)
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 you API Here")
req.Header.Add("X-SECRET-KEY", "Enter your 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_Zone_Prices.php HTTP/1.1
Host: www.iwantfuel.tech
Content-Type: application/json
X-API-KEY: Enter you API Here
X-SECRET-KEY: Enter your Secret Key Here
Content-Length: 23
{
"Fuel_Zone": "9C"
}
Java - OkHttp
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"Fuel_Zone\": \"9C\"\n}");
Request request = new Request.Builder()
.url("https://www.iwantfuel.tech/api/Get_Zone_Prices.php")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-KEY", "Enter you API Here")
.addHeader("X-SECRET-KEY", "Enter your 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_Zone_Prices.php")
.header("Content-Type", "application/json")
.header("X-API-KEY", "Enter you API Here")
.header("X-SECRET-KEY", "Enter your Secret Key Here")
.body("{\n \"Fuel_Zone\": \"9C\"\n}")
.asString();
JavaScript - Fetch
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-API-KEY", "Enter you API Here");
myHeaders.append("X-SECRET-KEY", "Enter your Secret Key Here");
const raw = JSON.stringify({
"Fuel_Zone": "9C"
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://www.iwantfuel.tech/api/Get_Zone_Prices.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_Zone_Prices.php",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"X-API-KEY": "Enter you API Here",
"X-SECRET-KEY": "Enter your Secret Key Here"
},
"data": JSON.stringify({
"Fuel_Zone": "9C"
}),
};
$.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({
"Fuel_Zone": "9C"
});
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_Zone_Prices.php");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("X-API-KEY", "Enter you API Here");
xhr.setRequestHeader("X-SECRET-KEY", "Enter your Secret Key Here");
xhr.send(data);
Kotlin - Okhttp
val client = OkHttpClient()
val mediaType = "application/json".toMediaType()
val body = "{\n \"Fuel_Zone\": \"9C\"\n}".toRequestBody(mediaType)
val request = Request.Builder()
.url("https://www.iwantfuel.tech/api/Get_Zone_Prices.php")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-KEY", "Enter you API Here")
.addHeader("X-SECRET-KEY", "Enter your 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_Zone_Prices.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 you API Here");
headers = curl_slist_append(headers, "X-SECRET-KEY: Enter your Secret Key Here");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "{\n \"Fuel_Zone\": \"9C\"\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({
"Fuel_Zone": "9C"
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://www.iwantfuel.tech/api/Get_Zone_Prices.php',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': 'Enter you API Here',
'X-SECRET-KEY': 'Enter your 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_Zone_Prices.php',
'headers': {
'Content-Type': 'application/json',
'X-API-KEY': 'Enter you API Here',
'X-SECRET-KEY': 'Enter your 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({
"Fuel_Zone": "9C"
});
req.write(postData);
req.end();
NodeJs - Request
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://www.iwantfuel.tech/api/Get_Zone_Prices.php',
'headers': {
'Content-Type': 'application/json',
'X-API-KEY': 'Enter you API Here',
'X-SECRET-KEY': 'Enter your Secret Key Here'
},
body: JSON.stringify({
"Fuel_Zone": "9C"
})
};
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_Zone_Prices.php')
.headers({
'Content-Type': 'application/json',
'X-API-KEY': 'Enter you API Here',
'X-SECRET-KEY': 'Enter your Secret Key Here'
})
.send(JSON.stringify({
"Fuel_Zone": "9C"
}))
.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_Zone_Prices.php"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Content-Type": @"application/json",
@"X-API-KEY": @"Enter you API Here",
@"X-SECRET-KEY": @"Enter your Secret Key Here"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\n \"Fuel_Zone\": \"9C\"\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 \"Fuel_Zone\": \"9C\"\n}";;
let reqBody =
let uri = Uri.of_string "https://www.iwantfuel.tech/api/Get_Zone_Prices.php" in
let headers = Header.init ()
|> fun h -> Header.add h "Content-Type" "application/json"
|> fun h -> Header.add h "X-API-KEY" "Enter you API Here"
|> fun h -> Header.add h "X-SECRET-KEY" "Enter your 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_Zone_Prices.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 =>'{
"Fuel_Zone": "9C"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-API-KEY: Enter you API Here',
'X-SECRET-KEY: Enter your 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 you API Here',
'X-SECRET-KEY' => 'Enter your Secret Key Here'
];
$body = '{
"Fuel_Zone": "9C"
}';
$request = new Request('POST', 'https://www.iwantfuel.tech/api/Get_Zone_Prices.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_Zone_Prices.php');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Content-Type' => 'application/json',
'X-API-KEY' => 'Enter you API Here',
'X-SECRET-KEY' => 'Enter your Secret Key Here'
));
$request->setBody('{\n "Fuel_Zone": "9C"\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_Zone_Prices.php');
$request->setRequestMethod('POST');
$body = new http\Message\Body;
$body->append('{
"Fuel_Zone": "9C"
}');
$request->setBody($body);
$request->setOptions(array());
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-KEY' => 'Enter you API Here',
'X-SECRET-KEY' => 'Enter your 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 you API Here")
$headers.Add("X-SECRET-KEY", "Enter your Secret Key Here")
$body = @"
{
`"Fuel_Zone`": `"9C`"
}
"@
$response = Invoke-RestMethod 'https://www.iwantfuel.tech/api/Get_Zone_Prices.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({
"Fuel_Zone": "9C"
})
headers = {
'Content-Type': 'application/json',
'X-API-KEY': 'Enter you API Here',
'X-SECRET-KEY': 'Enter your Secret Key Here'
}
conn.request("POST", "/api/Get_Zone_Prices.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_Zone_Prices.php"
payload = json.dumps({
"Fuel_Zone": "9C"
})
headers = {
'Content-Type': 'application/json',
'X-API-KEY': 'Enter you API Here',
'X-SECRET-KEY': 'Enter your 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 you API Here',
'X-SECRET-KEY' = 'Enter your Secret Key Here'
)
body = '{
"Fuel_Zone": "9C"
}';
res <- VERB("POST", url = "https://www.iwantfuel.tech/api/Get_Zone_Prices.php", body = body, add_headers(headers))
cat(content(res, 'text'))
R - RCurl
library(RCurl)
headers = c(
"Content-Type" = "application/json",
"X-API-KEY" = "Enter you API Here",
"X-SECRET-KEY" = "Enter your Secret Key Here"
)
params = "{
\"Fuel_Zone\": \"9C\"
}"
res <- postForm("https://www.iwantfuel.tech/api/Get_Zone_Prices.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_Zone_Prices.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 you API Here"
request["X-SECRET-KEY"] = "Enter your Secret Key Here"
request.body = JSON.dump({
"Fuel_Zone": "9C"
})
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 you API Here".parse()?);
headers.insert("X-SECRET-KEY", "Enter your Secret Key Here".parse()?);
let data = r#"{
"Fuel_Zone": "9C"
}"#;
let json: serde_json::Value = serde_json::from_str(&data)?;
let request = client.request(reqwest::Method::POST, "https://www.iwantfuel.tech/api/Get_Zone_Prices.php")
.headers(headers)
.json(&json);
let response = request.send().await?;
let body = response.text().await?;
println!("{}", body);
Ok(())
}
Ruby - Httpie
printf '{
"Fuel_Zone": "9C"
}'| http --follow --timeout 3600 POST 'https://www.iwantfuel.tech/api/Get_Zone_Prices.php' \
Content-Type:'application/json' \
X-API-KEY:'Enter you API Here' \
X-SECRET-KEY:'Enter your Secret Key Here'
Shell - wget
wget --no-check-certificate --quiet \
--method POST \
--timeout=0 \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: Enter you API Here' \
--header 'X-SECRET-KEY: Enter your Secret Key Here' \
--body-data '{
"Fuel_Zone": "9C"
}' \
'https://www.iwantfuel.tech/api/Get_Zone_Prices.php'
Swift - URLSession
let parameters = "{\n \"Fuel_Zone\": \"9C\"\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://www.iwantfuel.tech/api/Get_Zone_Prices.php")!,timeoutInterval: Double.infinity)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("Enter you API Here", forHTTPHeaderField: "X-API-KEY")
request.addValue("Enter your 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()