API Reference

This section provides detailed technical information about the Website Access Restriction Tool's configuration options and API endpoints.

Configuration

The Website Access Restriction Tool uses a JSON configuration file to define blocked websites and access rules. This configuration structure applies to version 4.4 of the tool.

Configuration File Structure

{
  "version": "4.4",
  "blocked_sites": [
    {
      "url": "example.com",
      "reason": "Time management",
      "enabled": true,
      "type": "domain"
    }
  ],
  "schedule": {
    "enabled": false,
    "active_hours": {
      "start": "09:00",
      "end": "17:00",
      "weekdays": [1, 2, 3, 4, 5]
    }
  },
  "notifications": {
    "enabled": true,
    "message": "This website is blocked by Website Access Restriction Tool"
  },
  "logging": {
    "enabled": true,
    "level": "info"
  },
  "advanced": {
    "use_hosts_file": true,
    "use_dns_filtering": true,
    "use_network_filtering": false
  }
}

Configuration Options

Option Type Description
version String The configuration format version (should be "4.4" for this version)
blocked_sites Array List of websites to block, with optional parameters
blocked_sites[].url String The URL or domain to block
blocked_sites[].reason String Reason for blocking this site
blocked_sites[].enabled Boolean Whether this blocking rule is active
blocked_sites[].type String The type of blocking ("domain", "url", "wildcard")
schedule.enabled Boolean Enable time-based blocking
schedule.active_hours.start String Start time for blocking (24-hour format)
schedule.active_hours.end String End time for blocking (24-hour format)
schedule.active_hours.weekdays Array Weekdays to apply blocking (1 = Monday, 7 = Sunday)
notifications.enabled Boolean Show blocking notifications
notifications.message String Custom message to display when sites are blocked
logging.enabled Boolean Enable logging of blocking events
logging.level String Logging level ("debug", "info", "warn", "error")
advanced.use_hosts_file Boolean Enable hosts file modification for blocking
advanced.use_dns_filtering Boolean Enable DNS-based filtering
advanced.use_network_filtering Boolean Enable network-level filtering

API Endpoints

The tool provides a REST API for programmatic control of website blocking features. All API requests require authentication using an API key generated in the application settings.

Base URL

The base URL for all API requests is http://localhost:8080/api/v1

Authentication

All API requests require an Authorization header with a bearer token:

Authorization: Bearer YOUR_API_KEY

Endpoints

GET /api/v1/blocked-sites

Returns a list of all blocked websites.

Response
{"status": "success", "data": [{"id": "1", "url": "example.com", "reason": "Time management", "enabled": true, "type": "domain"}]}
Example
curl -X GET "http://localhost:8080/api/v1/blocked-sites" \
     -H "Authorization: Bearer YOUR_API_KEY"

POST /api/v1/blocked-sites

Adds a new website to the block list.

Request Body
{"url": "example.com", "reason": "Time management", "enabled": true, "type": "domain"}
Response
{"status": "success", "data": {"id": "1", "url": "example.com", "reason": "Time management", "enabled": true, "type": "domain"}}
Example
curl -X POST "http://localhost:8080/api/v1/blocked-sites" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -d '{"url": "example.com", "reason": "Time management", "enabled": true, "type": "domain"}'

GET /api/v1/blocked-sites/{id}

Returns details of a specific blocked website.

Response
{"status": "success", "data": {"id": "1", "url": "example.com", "reason": "Time management", "enabled": true, "type": "domain"}}
Example
curl -X GET "http://localhost:8080/api/v1/blocked-sites/1" \
     -H "Authorization: Bearer YOUR_API_KEY"

PUT /api/v1/blocked-sites/{id}

Updates a blocked website.

Request Body
{"url": "example.com", "reason": "Productivity", "enabled": true, "type": "domain"}
Response
{"status": "success", "data": {"id": "1", "url": "example.com", "reason": "Productivity", "enabled": true, "type": "domain"}}
Example
curl -X PUT "http://localhost:8080/api/v1/blocked-sites/1" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -d '{"url": "example.com", "reason": "Productivity", "enabled": true, "type": "domain"}'

DELETE /api/v1/blocked-sites/{id}

Removes a website from the block list.

Response
{"status": "success", "message": "Site removed from block list"}
Example
curl -X DELETE "http://localhost:8080/api/v1/blocked-sites/1" \
     -H "Authorization: Bearer YOUR_API_KEY"

GET /api/v1/settings

Returns current system settings.

Response
{"status": "success", "data": {"version": "4.4", "logging": {"enabled": true, "level": "info"}, "advanced": {"use_hosts_file": true}}}
Example
curl -X GET "http://localhost:8080/api/v1/settings" \
     -H "Authorization: Bearer YOUR_API_KEY"

Troubleshooting

Common issues and their solutions when using the Website Access Restriction Tool.

Common Issues

Websites not being blocked

  • Check if the application is running with administrator privileges
  • Verify the website URL format in the configuration
  • Ensure the blocking service is active

Configuration not saving

  • Check file permissions for the configuration file
  • Ensure the application directory is not read-only
  • Restart the application after making changes

Legacy Version Usage Instructions

We are committed to providing users with the best product experience and technical support. With the continuous development of technology, we have had to adjust our support strategy for older versions:

Versions No Longer Supported

Except for versions 1+ and 2+, all other older versions (including but not limited to v0.1-v1.0, v2.0-v2.9, etc.) are no longer supported. This means:

Reasons for Discontinuation

  1. Outdated Technology: Older versions are based on outdated technical architectures and cannot adapt to modern operating systems and browser environments
  2. Security Risks: Older versions have potential security vulnerabilities that cannot be fixed in a timely manner
  3. High Maintenance Costs: Maintaining multiple versions simultaneously diverts development resources, affecting the iteration speed of new versions
  4. Large Function Differences: Older versions have significant functional differences from the current version, resulting in high support costs

Recommended Upgrade Path

If you are still using an unsupported older version, we strongly recommend upgrading to the latest version:

  1. Back up your current configuration data (if any)
  2. Uninstall the old version of the software
  3. Download the latest version from our official website: https://websiteblocker.vercel.app/download
  4. Install the latest version and reconfigure your settings
Important Note

Continuing to use unsupported older versions may cause the software to not work properly, pose security risks, and may be incompatible with new operating systems. Please upgrade to the latest version as soon as possible for the best experience and security.