SDKs overview

PurgoMalum provides a direct RESTful API for profanity detection and filtering, requiring no API key or authentication. The service is accessed via standard HTTP GET requests, making it compatible with any programming language capable of sending web requests. While PurgoMalum does not offer official, language-specific SDKs, the straightforward nature of its API allows developers to integrate its functionality using common HTTP client libraries available in most programming ecosystems.

The API supports various filtering operations, including replacing profanity with asterisks, removing profanity entirely, or checking for profanity without modification. Custom word lists can be provided as a query parameter to extend or modify the default filtering behavior PurgoMalum API documentation. This approach ensures broad compatibility and simplifies integration into diverse application architectures, from web services to desktop applications and mobile apps. The design aligns with principles of interoperability often associated with RESTful web services, which emphasize stateless operations and standard HTTP methods IETF RFC 7231 for HTTP/1.1 Semantics and Content.

Official SDKs by language

PurgoMalum operates exclusively through its RESTful API. As such, there are no traditional, pre-built SDKs officially maintained by PurgoMalum for specific programming languages. Integration typically involves using the native HTTP client capabilities or popular third-party HTTP libraries available in the chosen language. The table below illustrates common approaches for interaction:

Language Package/Method Typical Install Command Maturity
Java java.net.http.HttpClient or Apache HttpClient Add to pom.xml (Maven) or build.gradle (Gradle) for Apache HttpClient Stable (native) / Mature (Apache HttpClient)
Python requests library pip install requests Mature
PHP file_get_contents() or Guzzle HTTP Client composer require guzzlehttp/guzzle Stable (native) / Mature (Guzzle)
JavaScript (Node.js) node-fetch or Axios npm install node-fetch or npm install axios Mature
cURL (shell) Built-in Pre-installed on most Unix-like systems Mature

Installation

Since PurgoMalum provides a RESTful API and not language-specific SDKs, installation involves setting up an HTTP client in your preferred programming environment. The primary methods generally include:

  1. Using Native HTTP Clients: Most modern programming languages include built-in classes or functions for making HTTP requests. For example, Python has urllib.request, Java has java.net.http.HttpClient, and JavaScript in browsers uses fetch or XMLHttpRequest.
  2. Using Third-Party HTTP Libraries: Many languages have widely adopted, feature-rich HTTP client libraries that simplify request handling, error management, and response parsing. These are often preferred for their ease of use and advanced features. Examples include Python's requests library, Java's Apache HttpClient, PHP's Guzzle, and JavaScript's Axios or node-fetch for Node.js environments.

Example Installation Steps (Python requests library):

To use the requests library in Python, which is a common choice for its simplicity:

  1. Ensure Python is installed: Verify your Python installation by running python --version or python3 --version in your terminal.
  2. Install pip (if not already present): pip is the package installer for Python. It's usually included with Python distributions. If not, follow instructions from the pip installation guide.
  3. Install the requests library: Open your terminal or command prompt and execute:
pip install requests

This command downloads and installs the requests library and its dependencies, making it available for import in your Python scripts.

Quickstart example

The following quickstart examples demonstrate how to make a basic request to the PurgoMalum API using common HTTP client methods in different languages. These examples filter a given text by replacing profanity with asterisks, which is the default behavior if no other action is specified in the URL PurgoMalum API documentation.

Python

import requests

text_to_filter = "This is a test with some badword here."
api_url = f"https://www.purgomalum.com/service/containsprofanity?text={text_to_filter}"

try:
    response = requests.get(api_url)
    response.raise_for_status()  # Raise an exception for HTTP errors
    filtered_text = response.text
    print(f"Original text: {text_to_filter}")
    print(f"API response (boolean): {filtered_text}") # Note: containsProfanity returns boolean

    api_url_filter = f"https://www.purgomalum.com/service/plain?text={text_to_filter}"
    response_filter = requests.get(api_url_filter)
    response_filter.raise_for_status()
    filtered_string = response_filter.text
    print(f"Filtered string: {filtered_string}")

except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

JavaScript (Node.js with node-fetch)

const fetch = require('node-fetch'); // For Node.js; browsers use native fetch

async function filterText() {
    const textToFilter = "This is a test with some badword here.";
    const apiUrl = `https://www.purgomalum.com/service/containsprofanity?text=${encodeURIComponent(textToFilter)}`;

    try {
        let response = await fetch(apiUrl);
        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }
        let containsProfanity = await response.text();
        console.log(`Original text: ${textToFilter}`);
        console.log(`API response (boolean): ${containsProfanity}`);

        const apiUrlFilter = `https://www.purgomalum.com/service/plain?text=${encodeURIComponent(textToFilter)}`;
        let responseFilter = await fetch(apiUrlFilter);
        if (!responseFilter.ok) {
            throw new Error(`HTTP error! status: ${responseFilter.status}`);
        }
        let filteredString = await responseFilter.text();
        console.log(`Filtered string: ${filteredString}`);

    } catch (error) {
        console.error(`An error occurred: ${error}`);
    }
}

filterText();

PHP

<?php

$textToFilter = "This is a test with some badword here.";
$apiUrl = "https://www.purgomalum.com/service/containsprofanity?text=" . urlencode($textToFilter);

$response = @file_get_contents($apiUrl);

if ($response === FALSE) {
    echo "Error making API request.";
} else {
    echo "Original text: " . $textToFilter . "\n";
    echo "API response (boolean): " . $response . "\n";

    $apiUrlFilter = "https://www.purgomalum.com/service/plain?text=" . urlencode($textToFilter);
    $responseFilter = @file_get_contents($apiUrlFilter);

    if ($responseFilter === FALSE) {
        echo "Error making API request for filtering.";
    } else {
        echo "Filtered string: " . $responseFilter . "\n";
    }
}

?>

cURL (shell command)

TEXT_TO_FILTER="This is a test with some badword here."

# Check for profanity
curl "https://www.purgomalum.com/service/containsprofanity?text=${TEXT_TO_FILTER}"

# Filter profanity (default to asterisks)
curl "https://www.purgomalum.com/service/plain?text=${TEXT_TO_FILTER}"

Community libraries

Given PurgoMalum's direct RESTful API approach, most integrations rely on standard HTTP client libraries. However, community contributions sometimes emerge to wrap such APIs into more convenient, language-specific modules, often providing helper functions for common operations. For PurgoMalum, such community-maintained wrappers are less common due to the API's inherent simplicity, which often makes a dedicated wrapper unnecessary PurgoMalum API documentation.

Developers typically build their own utility functions or small client classes tailored to their application's specific needs, leveraging the flexibility of direct HTTP requests. When searching for community-contributed libraries, common repositories such as GitHub or language-specific package managers (e.g., PyPI for Python, npm for JavaScript) are the primary places to look. Users are advised to review the source code and community support of any third-party library before integrating it into production systems, as these are not officially maintained or endorsed by PurgoMalum.