• Your shopping cart is empty!
Neighboring Countries by ISO3166-2 Country Code

GeoDataSource™ Neighboring Countries Web Service

GeoDataSource™ Neighboring Countries Web Service is a REST API enables user to lookup the associated land border countries (the neighboring countries) based on the input of country code in ISO3166-2 format. It will return the result in either JSON or XML containing the information of the neighboring countries code and name. Paid plan of this Web Service will be auto-renewed and auto-recharged monthly. Below please find the syntax.

Product Name Price
Neighboring Countries Web Service (500 credits) FREE Add to cart
Neighboring Countries Web Service (50,000 credits) $50.00 USD/month Add to cart
Neighboring Countries Web Service (250,000 credits) $125.00 USD/month Add to cart
Neighboring Countries Web Service (1,000,000 credits) $300.00 USD/month Add to cart

GET https://api.geodatasource.com/v2/neighboring-countries


  • No database to download, to install or to upgrade in the server-side
  • Support HTTP or HTTPS queries up to 500 times per month


Parameter Type Description
key string (required) API key.
country_code char (required) ISO3166-2 Country code.
format string (optional) Return the result in json (default) or xml format.
Valid values: json | xml


Parameter Type Description
country_code string Neighboring two-character country code based on ISO 3166.
country_name string Neighboring country name.

Example of response message


Neighboring Countries API Sample Code
$apiKey = 'Enter_API_Key';
$params['format']   = 'json';
$params['country_code']  = 'US';

$query = '';

foreach($params as $key=>$value){
	$query .= '&' . $key . '=' . rawurlencode($value);

//For https request, please make sure you have enabled php_openssl.dll extension.
//How to enable https
//- Uncomment ;extension=php_openssl.dll by removing the semicolon in your php.ini, and restart the apache.
//In case you have difficulty to modify the php.ini, you can always make the http request instead of https.
$result = file_get_contents('https://api.geodatasource.com/neighboring-countries?key=' . $apiKey . $query);

$data = json_decode($result);

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class GDS {
	public static void main(String[] args) {
		try {

		URL url = new URL("https://api.geodatasource.com/neighboring-countries?key=Enter_API_Key&format=json&country_code=US");
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
		conn.setRequestProperty("Accept", "application/json");

		if (conn.getResponseCode() != 200) {
			throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());

		BufferedReader br = new BufferedReader(new InputStreamReader(

		String output;

		while ((output = br.readLine()) != null) {


	  } catch (MalformedURLException e) {


	  } catch (IOException e) {
Imports System.Net
Imports System.Security.Cryptography

Partial Public Class _Default
	Inherits System.Web.UI.Page

	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		Dim request As HttpWebRequest = Nothing
		Dim response As Net.HttpWebResponse = Nothing
		Dim stream As IO.Stream = Nothing

		Dim apiKey As String = "Enter_API_Key"
		Dim format As String = "json"
		Dim country_code As String = "US"

		request = Net.WebRequest.Create("https://api.geodatasource.com/neighboring-countries?key=" & apiKey & _
		"&format=" & System.Web.HttpUtility.UrlEncode(format) & _
		"&country_code=" & System.Web.HttpUtility.UrlEncode(country_code)

		request.Method = "GET"
		response = request.GetResponse()

		Dim reader As System.IO.StreamReader = New IO.StreamReader(response.GetResponseStream())

	End Sub
End Class
using Microsoft.VisualBasic;
using System
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Net;
using System.Security.Cryptography;

public partial class _Default : System.Web.UI.Page

	protected void Page_Load(object sender, System.EventArgs e)
		HttpWebRequest request = null;
		System.Net.HttpWebResponse response = null;
		System.IO.Stream stream = null;

		string apiKey = "Enter_API_Key";
		string format = "json";
		string country_code = "US";

		request = System.Net.WebRequest.Create("https://api.geodatasource.com/neighboring-countries?key=" + apiKey + "&format=" + System.Web.HttpUtility.UrlEncode(format) + "&country_code=" + System.Web.HttpUtility.UrlEncode(country_code));

		request.Method = "GET";
		response = request.GetResponse();

		System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());

import httplib
import urllib

p = { 'key': 'Enter_API_Key', 'format': 'json', 'country_code': 'US' }

conn = httplib.HTTPConnection("api.geodatasource.com")
conn.request("GET", "/neighboring-countries?" + urllib.urlencode(p))
res = conn.getresponse()
print res.read()
$ curl https://api.geodatasource.com/neighboring-countries?key=Enter_API_Key&format=json&country_code=US
require 'uri'
require 'net/http'

uri = URI.parse("https://api.geodatasource.com/neighboring-countries?key=Enter_API_Key&format=json&country_code=US")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri)

response = http.request(request)
print response.body
Error Codes

error_code error_message
10000 Missing parameter.
10001 Invalid API key.
10002 API key disabled.
10003 API key expired.
10004 Insufficient credits.
10005 Unknown error.
10006 No record found.
10007 Invalid format value.
10008 Invalid ISO3166-2 country code.

Example of error message

    "error": {
        "error_code": 10000,
        "error_message": "Missing parameter."