hypernic/nawala

Hypernic Nawala is a PHP library to check whether a website or domain is blocked in Indonesia.

Maintainers

Package info

github.com/hypernic/nawala

pkg:composer/hypernic/nawala

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.2 2025-09-11 16:26 UTC

This package is auto-updated.

Last update: 2026-03-11 17:27:59 UTC


README

A PHP library to check whether a website or domain is blocked in Indonesia.

Requirements

  • PHP >= 8.0
  • curl, json
  • intl optional for IDN domains

Installation

composer require hypernic/nawala

Quick Start

index.php:

<?php
declare(strict_types=1);

header('Content-Type: application/json');
require __DIR__ . '/vendor/autoload.php';

use Hypernic\Nawala;

$nawala = new Nawala([
    'timeout' => 10,          // seconds
    'connect_timeout' => 5,   // seconds
    'retries' => 1,           // light retry for transient errors
    'cache' => [
        'enabled' => true
    ]
]);

$result = $nawala->check('example.com');
echo json_encode($result, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

Example output (success, not blocked):

{
  "status": true,
  "data": {
    "domain": "example.com",
    "blocked": false
  }
}

Example output (success, blocked):

{
  "status": true,
  "data": {
    "domain": "pornhub.com",
    "blocked": true
  }
}

Example output (invalid input):

{ "status": false, "error": "domain is not valid" }

API

Class: Hypernic\Nawala

__construct(array $config = [])

Config options:

  • timeout (int, default 15): request timeout.
  • connect_timeout (int, default 10): connection timeout.
  • retries (int, default 1): retry count for transient errors (408, 429, 5xx).

check(string $domain): array

  • Normalizes the domain (lowercase, strips scheme, trims trailing dot).

  • Supports IDN via intl when available.

  • Calls the Komdigi endpoint and maps result:

    • blocked = true when Status === "Ada".

How It Works

  • Data source: https://trustpositif.komdigi.go.id.

  • Flow:

    1. Normalize domain + IDN handling.
    2. POST to the public endpoint.
    3. Pick the most relevant row and determine blocked.

Note: The upstream service may change without notice. Handle network failures and schema changes in your application.

Testing

This project includes PHPUnit tests.

./vendor/bin/phpunit --bootstrap vendor/autoload.php tests/test.php

Notes

  • Subject to Komdigi availability and rate limits.
  • Upstream HTML/token/endpoint changes may require library updates.
  • Results reflect the status at query time only.