SDKs overview

Geokeo offers a suite of APIs for geospatial data operations, including converting addresses to geographic coordinates (geocoding), converting coordinates back to addresses (reverse geocoding), and identifying location based on IP addresses (IP geolocation). To facilitate integration, Geokeo provides official SDKs and supports various programming languages through code examples, enabling developers to incorporate these functionalities into their applications with less direct interaction with the underlying HTTP API endpoints. While Geokeo maintains official documentation and code samples, community-contributed libraries may also exist, offering alternative approaches or language support not covered by direct vendor offerings.

The primary advantage of using an SDK or library over direct API calls is the abstraction of common tasks such as request formatting, response parsing, error handling, and authentication. This reduces boilerplate code and streamlines the development process, allowing developers to focus on application logic rather than low-level API interactions. For Geokeo, this means simpler access to features like fetching latitude and longitude for a given address or determining a city from an IP address.

Official SDKs by language

Geokeo focuses on providing comprehensive documentation and direct code examples rather than formal, versioned SDKs in the traditional sense. These examples serve a similar purpose to SDKs by demonstrating how to interact with the API in specific programming environments. The primary language examples provided cover widely used environments for web and server-side development. Developers can adapt these examples to build their own wrapper functions or use them directly in their applications.

The following table outlines the languages for which Geokeo provides official code examples and guidance within its documentation. While not discrete SDK packages, these resources are functionally equivalent for quick integration.

Language Package/Approach Installation/Usage Maturity
cURL Direct HTTP request Included in most Unix-like systems, widely available for Windows. Execute directly from command line. Stable (API reference)
Python Standard library (requests) pip install requests Stable (Code examples)
JavaScript Browser/Node.js fetch API, axios npm install axios (for Node.js) or native fetch Stable (Code examples)
PHP Standard library (curl extension) Included in most PHP installations, no extra installation usually needed for curl extension. Stable (Code examples)

Installation

Installing the necessary components to interact with the Geokeo API primarily involves setting up the HTTP client library for your chosen programming language. Geokeo's approach emphasizes using standard, widely adopted libraries rather than proprietary SDK packages. This typically means installing a common HTTP client if it's not already part of the language's standard library.

Python

For Python, the requests library is a common choice for making HTTP requests due to its user-friendly API. You can install it using pip:

pip install requests

JavaScript (Node.js)

In Node.js environments, several HTTP clients are available. axios is a popular promise-based HTTP client that simplifies API interactions:

npm install axios

Alternatively, the native fetch API can be used in modern Node.js versions (v18+) and web browsers without additional installations, as detailed in MDN Web Docs on using Fetch.

PHP

PHP often utilizes its built-in cURL extension for HTTP requests. This extension is usually enabled by default or can be activated in the php.ini configuration. No specific package installation is typically required beyond ensuring the extension is active.

cURL

cURL is a command-line tool and library for transferring data with URLs. It is pre-installed on most Unix-like operating systems and is available for Windows. No separate installation step is usually needed to use cURL from the command line.

Quickstart example

The following examples demonstrate how to perform a basic geocoding request to the Geokeo API using Python and JavaScript. These examples assume you have an API key, which is required for authentication and rate limiting. Replace YOUR_API_KEY with your actual Geokeo API key obtained from your Geokeo account dashboard.

Python Example (Geocoding)

This Python snippet uses the requests library to query the Geokeo geocoding API for a specific address.

import requests

api_key = "YOUR_API_KEY"
address = "1600 Amphitheatre Parkway, Mountain View, CA"
url = f"https://geokeo.com/geocode/v1/search.php?q={address}&api={api_key}"

try:
    response = requests.get(url)
    response.raise_for_status()  # Raise an HTTPError for bad responses (4xx or 5xx)
    data = response.json()

    if data and data['status'] == 'ok' and data['results']:
        first_result = data['results'][0]
        print(f"Address: {first_result['formatted_address']}")
        print(f"Latitude: {first_result['geometry']['lat']}")
        print(f"Longitude: {first_result['geometry']['lng']}")
    elif data['status'] == 'error':
        print(f"API Error: {data['message']}")
    else:
        print("No results found or unexpected response structure.")

except requests.exceptions.RequestException as e:
    print(f"Request failed: {e}")
except ValueError as e: # Catch JSON decoding errors
    print(f"Failed to decode JSON: {e}")

JavaScript Example (Node.js with Fetch API for Geocoding)

This JavaScript snippet demonstrates a geocoding request using the native Fetch API, suitable for both Node.js (v18+) and modern browser environments.

const apiKey = "YOUR_API_KEY";
const address = "20 W 34th St, New York, NY";
const url = `https://geokeo.com/geocode/v1/search.php?q=${encodeURIComponent(address)}&api=${apiKey}`;

async function geocodeAddress() {
    try {
        const response = await fetch(url);
        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }
        const data = await response.json();

        if (data && data.status === 'ok' && data.results) {
            const firstResult = data.results[0];
            console.log(`Address: ${firstResult.formatted_address}`);
            console.log(`Latitude: ${firstResult.geometry.lat}`);
            console.log(`Longitude: ${firstResult.geometry.lng}`);
        } else if (data.status === 'error') {
            console.error(`API Error: ${data.message}`);
        } else {
            console.log("No results found or unexpected response structure.");
        }
    } catch (error) {
        console.error("Fetch error:", error);
    }
}

geocodeAddress();

Community libraries

As of late 2024, Geokeo's ecosystem primarily relies on detailed API documentation and code examples for various languages. While official SDKs are not provided as separate installable packages, the clear API structure and simple HTTP request model make it straightforward for developers to create custom wrappers or integrate directly using standard HTTP client libraries. There are no widely recognized, independently maintained community-produced SDKs or libraries that abstract the Geokeo API into a high-level client for specific languages beyond what is demonstrated in the official documentation.

Developers looking for more specialized functionality or a different integration pattern than what is offered directly by Geokeo's examples may consider developing their own client libraries. Such libraries typically encapsulate API key management, request retry logic, and structured response parsing specific to their application's needs. Given the straightforward nature of the Geokeo API, building a minimalist client wrapper is a manageable task for most development teams.

For those interested in contributing to the Geokeo ecosystem or sharing utility functions, platforms like GitHub are common venues for open-source projects. However, any such contributions would be independent of Geokeo's official support and should be evaluated based on their community adoption and maintenance status.