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/countryassociation/associate?name=Maria&limit=5&api_key=swa_your_key
curl -X POST https://simplewebapis.com/api/countryassociation \
-H "Content-Type: application/json" \
-H "X-Api-Key: swa_your_key" \
-d '{"name": "Maria", "limit": 5}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Api-Key", "swa_your_key");
var payload = new { name = "Maria", limit = 5 };
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://simplewebapis.com/api/countryassociation", content);
var result = await response.Content
.ReadFromJsonAsync<CountryAssociationResponse>();
Console.WriteLine(result?.Data?.Countries.FirstOrDefault()?.Country);
// -- Response model --
record CountryAssociationResponse(
bool Success,
string? Message,
CountryAssociationData? Data);
record CountryAssociationData(
string Name,
long SampleSize,
List<CountryAssociationItem> Countries,
List<string> Sources);
record CountryAssociationItem(
string IsoCode,
string Country,
double Probability);
$ch = curl_init('https://simplewebapis.com/api/countryassociation');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Api-Key: swa_your_key',
],
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Maria',
'limit' => 5,
]),
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
echo $data['data']['countries'][0]['country'];
const response = await fetch('https://simplewebapis.com/api/countryassociation', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Api-Key': 'swa_your_key',
},
body: JSON.stringify({
name: 'Maria',
limit: 5,
}),
});
const result = await response.json();
console.log(result.data.countries[0].country);
import requests
response = requests.post(
'https://simplewebapis.com/api/countryassociation',
headers={
'Content-Type': 'application/json',
'X-Api-Key': 'swa_your_key',
},
json={'name': 'Maria', 'limit': 5},
)
data = response.json()
print(data['data']['countries'][0]['country'])
body, _ := json.Marshal(map[string]any{
"name": "Maria",
"limit": 5,
})
req, _ := http.NewRequest("POST",
"https://simplewebapis.com/api/countryassociation",
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()
var result map[string]any
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result["data"])
require 'net/http'
require 'json'
uri = URI('https://simplewebapis.com/api/countryassociation')
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 = { name: 'Maria', limit: 5 }.to_json
response = http.request(request)
data = JSON.parse(response.body)
puts data['data']['countries'][0]['country']
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://simplewebapis.com/api/countryassociation"))
.header("Content-Type", "application/json")
.header("X-Api-Key", "swa_your_key")
.POST(HttpRequest.BodyPublishers.ofString(
"{\"name\":\"Maria\",\"limit\":5}"))
.build();
var response = client.send(request,
HttpResponse.BodyHandlers.ofString());
var mapper = new ObjectMapper();
var result = mapper.readTree(response.body());
System.out.println(result.get("data").get("countries").get(0).get("country"));
let client = reqwest::blocking::Client::new();
let response = client
.post("https://simplewebapis.com/api/countryassociation")
.header("Content-Type", "application/json")
.header("X-Api-Key", "swa_your_key")
.json(&serde_json::json!({
"name": "Maria",
"limit": 5,
}))
.send()?;
let result: serde_json::Value = response.json()?;
println!("{}", result["data"]["countries"][0]["country"]);