Warning: Passing your API key as a query parameter exposes it in server logs, browser history, and referrer headers. Only use this method in server-to-server or controlled environments.
https://simplewebapis.com/api/barcode/generate?text=Hello%20World&format=code128&width=400&height=150&api_key=swa_your_key
curl -X POST https://simplewebapis.com/api/barcode \
-H "Content-Type: application/json" \
-H "X-Api-Key: swa_your_key" \
-d '{"text": "Hello World", "format": "code128", "width": 400, "height": 150}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Api-Key", "swa_your_key");
var payload = new { text = "Hello World", format = "code128", width = 400, height = 150 };
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://simplewebapis.com/api/barcode", content);
var imageBytes = await response.Content.ReadAsByteArrayAsync();
await File.WriteAllBytesAsync("barcode.png", imageBytes);
$ch = curl_init('https://simplewebapis.com/api/barcode');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Api-Key: swa_your_key',
],
CURLOPT_POSTFIELDS => json_encode([
'text' => 'Hello World',
'format' => 'code128',
'width' => 400,
'height' => 150,
]),
CURLOPT_RETURNTRANSFER => true,
]);
$image = curl_exec($ch);
curl_close($ch);
file_put_contents('barcode.png', $image);
const response = await fetch('https://simplewebapis.com/api/barcode', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Api-Key': 'swa_your_key',
},
body: JSON.stringify({
text: 'Hello World',
format: 'code128',
width: 400,
height: 150,
}),
});
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const img = document.createElement('img');
img.src = url;
document.body.appendChild(img);
import requests
response = requests.post(
'https://simplewebapis.com/api/barcode',
headers={
'Content-Type': 'application/json',
'X-Api-Key': 'swa_your_key',
},
json={
'text': 'Hello World',
'format': 'code128',
'width': 400,
'height': 150,
},
)
with open('barcode.png', 'wb') as f:
f.write(response.content)
body, _ := json.Marshal(map[string]any{
"text": "Hello World",
"format": "code128",
"width": 400,
"height": 150,
})
req, _ := http.NewRequest("POST",
"https://simplewebapis.com/api/barcode",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Api-Key", "swa_your_key")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
data, _ := io.ReadAll(resp.Body)
os.WriteFile("barcode.png", data, 0644)
require 'net/http'
require 'json'
uri = URI('https://simplewebapis.com/api/barcode')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['X-Api-Key'] = 'swa_your_key'
request.body = {
text: 'Hello World',
format: 'code128',
width: 400,
height: 150,
}.to_json
response = http.request(request)
File.write('barcode.png', response.body)
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://simplewebapis.com/api/barcode"))
.header("Content-Type", "application/json")
.header("X-Api-Key", "swa_your_key")
.POST(HttpRequest.BodyPublishers.ofString(
"{\"text\":\"Hello World\",\"format\":\"code128\",\"width\":400,\"height\":150}"))
.build();
var response = client.send(request,
HttpResponse.BodyHandlers.ofByteArray());
Files.write(Paths.get("barcode.png"), response.body());
use std::fs::File;
use std::io::Write;
let client = reqwest::blocking::Client::new();
let response = client
.post("https://simplewebapis.com/api/barcode")
.header("Content-Type", "application/json")
.header("X-Api-Key", "swa_your_key")
.json(&serde_json::json!({
"text": "Hello World",
"format": "code128",
"width": 400,
"height": 150,
}))
.send()?;
let mut file = File::create("barcode.png")?;
file.write_all(&response.bytes()?)?;