SDKs overview

MuleSoft's approach to SDKs and libraries centers on extending the capabilities of the Anypoint Platform. These tools enable developers to programmatically interact with Mule applications, custom connectors, and API implementations. Official SDKs are primarily designed for specific language ecosystems, allowing for structured development within familiar environments.

The SDKs facilitate tasks such as developing custom connectors for new systems, building Mule extensions, or integrating MuleSoft's runtime engines into existing applications. Beyond official offerings, a robust community contributes libraries that address specific integration patterns or provide utilities for common development challenges. Understanding the scope and usage of both official and community resources is key for developers working within the MuleSoft ecosystem.

Official SDKs by language

MuleSoft provides official SDKs predominantly for Java, which is the foundational language for the Mule runtime engine. These SDKs are crucial for developing custom components, connectors, and extending the platform's core functionalities. While Java has the most comprehensive official SDKs, helper libraries or client components are available for other popular languages to interact with the Anypoint Platform APIs or deployed Mule applications.

Java SDKs

The primary official SDK for MuleSoft development is the Mule SDK for Java. This SDK allows developers to create custom connectors, modules, and extensions that run within the Mule runtime. It supports the development of components that can interact with external systems not supported by out-of-the-box connectors, or to implement specific business logic within the integration flow. Developers typically use Maven for dependency management with Java-based Mule projects.

Other official Java libraries include client SDKs for interacting with specific Anypoint Platform services, such as the API Manager API client library, which allows programmatic management of APIs.

Other languages

While not full-fledged SDKs for developing Mule runtime components, MuleSoft provides client libraries or recommends best practices for interacting with Anypoint Platform APIs from languages like Node.js, Python, and .NET. These typically involve RESTful API calls using standard HTTP client libraries available in each language.

For example, to interact with the Anypoint Platform's various APIs (e.g., Runtime Manager, Exchange, Access Management) from Python, developers would use HTTP request libraries like requests. Similarly, Node.js applications would use axios or the built-in http module, and .NET applications would use HttpClient to consume these APIs. The focus in these languages is on client-side interaction rather than extending the Mule runtime directly.

Official SDKs and Libraries Table

Language Primary SDK / Library Package Manager / Tool Maturity Key Use Cases
Java Mule SDK (for custom components) Maven Mature, Actively Maintained Custom connectors, modules, runtime extensions
Java Anypoint Platform API Clients Maven Stable, Maintained Programmatic Anypoint Platform management
Node.js (HTTP Client Libraries like axios) npm Standard (language ecosystem) Interacting with Anypoint Platform APIs, consuming Mule APIs
Python (HTTP Client Libraries like requests) pip Standard (language ecosystem) Interacting with Anypoint Platform APIs, consuming Mule APIs
.NET (HTTP Client Libraries like HttpClient) NuGet Standard (language ecosystem) Interacting with Anypoint Platform APIs, consuming Mule APIs

Installation

Installation of MuleSoft SDKs and libraries depends on the specific language and project type.

Java (Mule SDK)

For Java-based Mule SDK development, Apache Maven is the standard build automation tool. Developers typically add the Mule SDK dependencies to their project's pom.xml file. Anypoint Studio, MuleSoft's integrated development environment (IDE), includes Maven integration and simplifies project setup for Mule extensions.

<dependency>
    <groupId>org.mule.sdk</groupId>
    <artifactId>mule-sdk-api</artifactId>
    <version>1.2.0</version> <!-- Use the latest version -->
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.mule.sdk</groupId>
    <artifactId>mule-sdk-core</artifactId>
    <version>1.2.0</version> <!-- Use the latest version -->
    <scope>provided</scope>
</dependency>

These dependencies are marked as provided because the Mule runtime provides them when the extension is deployed.

Node.js

For Node.js, interaction with MuleSoft APIs typically involves installing standard HTTP client libraries via npm. For example, to make REST API calls:

npm install axios

Python

Python developers use pip to install HTTP client libraries. The requests library is a common choice:

pip install requests

.NET

In .NET environments, the HttpClient class is part of the standard library, so no explicit installation is required for basic HTTP requests. For more advanced features or specific platform integration, NuGet packages might be used.

Quickstart example

This quickstart example demonstrates how a Python application can interact with a deployed Mule API Gateway or an API published through the Anypoint Platform. This example fetches information about an API using the Anypoint Platform APIs; it assumes you have appropriate authentication credentials (e.g., a connected app client ID and secret).

First, obtain an access token from the Anypoint Platform Access Management API by following the Anypoint Platform Get Started guide for API access.

Python example: Fetching API details

This Python snippet uses the requests library to authenticate and then query the Anypoint Platform to list APIs in an organization. Replace placeholders with your actual Anypoint Platform details.


import requests
import json

# Anypoint Platform credentials and environment
ANYPOINT_USERNAME = "your_username"
ANYPOINT_PASSWORD = "your_password"
ORGANIZATION_ID = "your_organization_id" # Found in Access Management -> Organizations

# 1. Obtain an access token
def get_access_token(username, password):
    auth_url = "https://anypoint.mulesoft.com/accounts/login"
    headers = {"Content-Type": "application/json"}
    payload = {
        "username": username,
        "password": password
    }
    try:
        response = requests.post(auth_url, headers=headers, json=payload)
        response.raise_for_status() # Raise an HTTPError for bad responses (4xx or 5xx)
        return response.json()["access_token"]
    except requests.exceptions.RequestException as e:
        print(f"Error obtaining access token: {e}")
        return None

# 2. List APIs in your organization
def list_apis(access_token, org_id):
    apis_url = f"https://anypoint.mulesoft.com/apimanager/api/v1/organizations/{org_id}/apis"
    headers = {
        "Authorization": f"Bearer {access_token}",
        "Content-Type": "application/json"
    }
    try:
        response = requests.get(apis_url, headers=headers)
        response.raise_for_status()
        return response.json()
    except requests.exceptions.RequestException as e:
        print(f"Error listing APIs: {e}")
        return None

if __name__ == "__main__":
    access_token = get_access_token(ANYPOINT_USERNAME, ANYPOINT_PASSWORD)

    if access_token:
        print("Successfully obtained access token.")
        apis_data = list_apis(access_token, ORGANIZATION_ID)

        if apis_data:
            print("APIs in your organization:")
            for api in apis_data["data"]:
                print(f"  API Name: {api['name']}, ID: {api['id']}, Status: {api['status']}")
        else:
            print("Could not retrieve APIs.")
    else:
        print("Failed to authenticate with Anypoint Platform.")

Before running this code, ensure you have Python and the requests library installed (pip install requests). Replace "your_username", "your_password", and "your_organization_id" with your actual Anypoint Platform credentials and organization ID.

Community libraries

The MuleSoft community contributes various open-source libraries and connectors that extend the Anypoint Platform. These resources are often available on platforms like GitHub or through MuleSoft's Anypoint Exchange as community-maintained assets.

Community contributions can range from specialized connectors for less common systems, utility modules for complex data transformations, to templates for common integration patterns. Examples might include custom policy implementations, reusable flows, or client libraries for specific external APIs not covered by official connectors.

When considering community libraries, developers should evaluate factors such as maintenance activity, documentation quality, and compatibility with their specific Mule runtime version. While not officially supported by MuleSoft, many community projects are well-maintained and provide valuable extensions to the platform. Exploring Anypoint Exchange or public repositories like MuleSoft's GitHub organization are good starting points for discovering these resources.