SDKs overview
CitySDK provides a collection of Software Development Kits (SDKs) and libraries designed to simplify the integration of urban data into applications. These tools are primarily open-source and facilitate interaction with the CitySDK data models and services, which focus on various domains such as mobility, environment, and economy within urban environments. The SDKs abstract away direct HTTP requests to the underlying APIs, offering language-specific methods for data retrieval and manipulation. Developers can utilize these SDKs to build smart city applications, conduct urban analytics, or contribute to open data projects by connecting to CitySDK-compliant data sources. The official SDKs are maintained by the CitySDK project team, while community contributions extend the ecosystem with additional language bindings and specialized utilities, reflecting the project's collaborative nature as detailed in the CitySDK documentation.
The architecture of CitySDK's data services often involves RESTful APIs that return JSON payloads, a common pattern for web services, as described by the W3C on REST principles. The SDKs encapsulate these interactions, providing developers with idiomatic access patterns for their chosen programming language. This approach aims to lower the barrier to entry for developers working with complex urban datasets, enabling them to focus on application logic rather than low-level API communication.
Official SDKs by language
The CitySDK project maintains official SDKs for several popular programming languages, ensuring direct compatibility with the core CitySDK data models and API specifications. These SDKs are developed to provide stable and well-documented interfaces for accessing urban data endpoints.
| Language | Package Name | Install Command Example | Maturity |
|---|---|---|---|
| JavaScript (Node.js) | citysdk |
npm install citysdk |
Stable |
| Python | citysdk-py |
pip install citysdk-py |
Stable |
| Java | citysdk-java |
Maven: Add dependency (see CitySDK Java SDK documentation) | Stable |
Each official SDK is designed to align with the conventions and best practices of its respective language ecosystem, offering features such as:
- Data Retrieval: Methods to query various urban data categories (e.g., mobility, environment, demographics).
- Filtering and Pagination: Built-in support for common API query parameters to refine results and manage large datasets.
- Error Handling: Mechanisms to manage API-specific errors and network issues gracefully.
- Authentication (if applicable): Integration with any required authentication schemes, although CitySDK primarily focuses on open data.
Installation
Installing CitySDK's official libraries typically involves using the standard package manager for the chosen programming language. This ensures that dependencies are managed correctly and that the SDK is readily available for use in development projects.
JavaScript (Node.js)
npm install citysdk
This command installs the citysdk package from the npm registry, making it available for import in Node.js applications. Further details on Node.js package management are available in the npm install documentation.
Python
pip install citysdk-py
This command installs the citysdk-py package from PyPI, the Python Package Index. It can be used within any Python environment. For best practices, consider using virtual environments as described in the Python venv documentation.
Java
For Java projects, CitySDK's Java library is typically integrated via a build automation tool like Maven or Gradle. Below is an example for Maven:
Maven Dependency
<dependency>
<groupId>eu.citysdk</groupId>
<artifactId>citysdk-java</artifactId>
<version>1.0.0</version> <!-- Replace with the latest version -->
</dependency>
Replace 1.0.0 with the current stable version number, which can be found in the CitySDK Java SDK reference. This snippet should be added to the <dependencies> section of your project's pom.xml file.
Quickstart example
This section provides basic quickstart examples for accessing CitySDK data using the official SDKs. These examples illustrate common patterns for initializing the SDK and making a simple data request.
JavaScript (Node.js) Example: Fetching basic city data
This example demonstrates how to initialize the Node.js SDK and retrieve general information about a city.
const CitySDK = require('citysdk');
// Initialize CitySDK with a base URL (example for a generic CitySDK instance)
const citysdk = new CitySDK({
host: 'https://api.example.com/citysdk/v2' // Replace with your CitySDK API endpoint
});
async function getCityInfo(cityName) {
try {
const response = await citysdk.get('cities', { name: cityName });
console.log(`Information for ${cityName}:`);
console.log(response.data); // Assuming response.data contains the city information
} catch (error) {
console.error('Error fetching city info:', error.message);
}
}
getCityInfo('Amsterdam'); // Example call
Python Example: Querying mobility data
This Python snippet demonstrates how to use citysdk-py to query mobility data, such as public transport information, for a specified area or city.
from citysdk import CitySDK
# Initialize CitySDK client
citysdk = CitySDK(host='https://api.example.com/citysdk/v2') # Replace with your CitySDK API endpoint
def get_mobility_data(city_id):
try:
# Example: Fetching mobility data for a specific city ID
response = citysdk.get_data('mobility', city_id=city_id, limit=5)
print(f"Mobility data for city ID {city_id}:")
for item in response.get('features', [])[:5]: # Assuming geojson-like structure
print(item.get('properties'))
except Exception as e:
print(f"Error fetching mobility data: {e}")
get_mobility_data('nl.amsterdam') # Example call using a CitySDK ID
These examples illustrate the basic interaction patterns. Developers should consult the CitySDK official documentation for comprehensive API references, available endpoints, and specific query parameters relevant to different data domains.
Community libraries
Beyond the official SDKs, the open-source nature of CitySDK has fostered a community that contributes various libraries and tools. These community-driven projects can offer specialized functionalities, language bindings for less common languages, or integrations with other data platforms.
While not officially supported, these libraries often provide valuable extensions to the CitySDK ecosystem:
- Specialized Clients: Libraries built for specific use cases, such as real-time data streaming or advanced geospatial analysis, leveraging CitySDK data.
- Framework Integrations: Connectors or adapters to popular web frameworks (e.g., Django, Flask, Express.js) or data visualization tools.
- Alternative Language Bindings: Implementations in languages not covered by official SDKs, developed by users who prefer those environments.
Developers interested in community contributions are encouraged to explore CitySDK's GitHub repositories or community forums. It is important to verify the maintenance status, documentation, and licensing of any community library before integrating it into a production environment. The CitySDK GitHub organization is a primary resource for discovering these projects and understanding their current development status.
Community libraries often evolve based on specific project needs and can sometimes offer experimental features or different approaches to data interaction. Users should evaluate these against their project requirements and consider contributing back to the community to enhance these resources.