IBAN API Code Snippets

In this section, you can find a quick snippet to use the validation API through many popular programming languages and tools.

The snippets on this page demonstrate how to integrate with the IBAN validation API, It can also be used for different endpoints.

The PHP IBAN Validation code snippet

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.ibanapi.com/v1/validate',
  CURLOPT_USERAGENT=>'IBANAPI V1.0.0',
  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 => array('iban' => 'IBAN','api_key' => 'API_KEY'),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

The Nodejs IBAN Validation code snippet

This example is for the Nodejs Request library, This example is for IBAN validation, It can be used for other API requests as well.

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.ibanapi.com/v1/validate',
  'headers': {
  },
  formData: {
    'iban': 'IBAN',
    'api_key': 'API_KEY'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

NodeJS Axios IBAN Validation API Snippet

var axios = require('axios');
var FormData = require('form-data');
var data = new FormData();
data.append('iban', 'IBAN');
data.append('api_key', 'API_KEY');

var config = {
  method: 'post',
  url: 'https://api.ibanapi.com/v1/validate',
  headers: { 
    ...data.getHeaders()
  },
  data : data
};

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

The JAVA (OkHttp) IBAN Validation code snippet

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("iban","IBAN")
  .addFormDataPart("api_key","API_KEY")
  .build();
Request request = new Request.Builder()
  .url("https://api.ibanapi.com/v1/validate")
  .method("POST", body)
  .build();
Response response = client.newCall(request).execute();

The Python (Requests) IBAN Validation code snippet

import requests
url = "https://api.ibanapi.com/v1/validate"
payload={'iban': 'IBAN',
'api_key': 'API_KEY'}
fls=[
]

headers = {}
response = requests.request("POST", url, headers=headers, data=payload, files=fls)
print(response.text)

The C# (RestSharp) IBAN Validation code snippet

var client = new RestClient("https://api.ibanapi.com/v1/validate");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AlwaysMultipartFormData = true;
request.AddParameter("iban", "IBAN");
request.AddParameter("api_key", "API_KEY");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

The Dart (Http) IBAN Validation code snippet

var apiURL = "https://api.ibanapi.com/v1/validate";
var request = http.MultipartRequest('POST', Uri.parse(apiURL));
request.fields.addAll({
  'iban': 'IBAN',
  'api_key': 'API_KEY'
});


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

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