API Overview

The Web Defender API allows you to integrate our security features into your applications, automate security operations, and access your security data programmatically. Our RESTful API uses standard HTTP methods and returns JSON responses.

Base URL

https://api.webdefender.online/v1

API Versioning

The Web Defender API is versioned to ensure backward compatibility. The current version is v1. When a new version is released, the previous version will be supported for at least 12 months.

Content Type

All requests should include the Content-Type: application/json header. Responses will also be in JSON format.

Getting Started

To start using the API, you'll need to authenticate your requests using an API key.

Authentication

All API requests must be authenticated using an API key. You can generate an API key in the Web Defender dashboard under Settings > API.

API Key Authentication

Include your API key in the Authorization header of your requests:

Authorization: Bearer YOUR_API_KEY

Example Request

curl -X GET "https://api.webdefender.online/v1/websites" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -H "Content-Type: application/json"
Security Warning

Keep your API key secure and never share it publicly. If you believe your API key has been compromised, you can regenerate it in the dashboard.

Rate Limits

To ensure the stability and availability of the API, we enforce rate limits on API requests. The rate limits vary based on your subscription plan.

Plan Rate Limit Burst Limit
Free Trial 60 requests per minute 100 requests
Standard 300 requests per minute 500 requests
Enterprise 1,000 requests per minute 2,000 requests

Rate Limit Headers

Each API response includes headers that provide information about your current rate limit status:

X-RateLimit-Limit: 300
X-RateLimit-Remaining: 297
X-RateLimit-Reset: 1620000000
  • X-RateLimit-Limit: The maximum number of requests you can make per minute
  • X-RateLimit-Remaining: The number of requests remaining in the current minute
  • X-RateLimit-Reset: The time at which the rate limit will reset, in Unix time

Exceeding Rate Limits

If you exceed the rate limit, you'll receive a 429 Too Many Requests response. The response will include a Retry-After header indicating how many seconds to wait before making another request.

Error Handling

The Web Defender API uses standard HTTP status codes to indicate the success or failure of a request. In addition to the status code, error responses include a JSON body with more information about the error.

Error Response Format

{
  "error": {
    "code": "invalid_request",
    "message": "The request was invalid",
    "details": "The 'website_id' parameter is required"
  }
}

Common Error Codes

Status Code Error Code Description
400 invalid_request The request was invalid or malformed
401 unauthorized Authentication failed or was not provided
403 forbidden You don't have permission to access the resource
404 not_found The requested resource was not found
429 rate_limit_exceeded You've exceeded the rate limit
500 server_error An error occurred on the server

Handling Errors

When handling errors in your application, we recommend checking both the HTTP status code and the error code in the response body. This will give you more detailed information about what went wrong and how to fix it.

try {
  const response = await fetch('https://api.webdefender.online/v1/websites', {
    headers: {
      'Authorization': `Bearer ${apiKey}`,
      'Content-Type': 'application/json'
    }
  });
  
  if (!response.ok) {
    const error = await response.json();
    throw new Error(`${response.status}: ${error.error.message}`);
  }
  
  const data = await response.json();
  // Process data
} catch (error) {
  console.error('API Error:', error.message);
}

Websites API

The Websites API allows you to manage the websites protected by Web Defender. You can list, create, update, and delete websites, as well as configure their protection settings.

List Websites

Retrieve a list of all websites protected by Web Defender.

GET /websites
Example Request
curl -X GET "https://api.webdefender.online/v1/websites" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -H "Content-Type: application/json"
Example Response
{
  "data": [
    {
      "id": "ws_123456",
      "domain": "example.com",
      "protocol": "https",
      "created_at": "2023-01-15T12:00:00Z",
      "protection_level": "standard",
      "status": "active"
    },
    {
      "id": "ws_789012",
      "domain": "another-example.com",
      "protocol": "https",
      "created_at": "2023-02-20T15:30:00Z",
      "protection_level": "high",
      "status": "active"
    }
  ],
  "meta": {
    "total": 2,
    "per_page": 10,
    "current_page": 1,
    "last_page": 1
  }
}

Create Website

Add a new website to Web Defender for protection.

POST /websites
Request Parameters
Parameter Type Required Description
domain string Yes The domain name of the website (e.g., example.com)
protocol string Yes The protocol used by the website (http or https)
protection_level string No The protection level (low, standard, high). Default: standard
Example Request
curl -X POST "https://api.webdefender.online/v1/websites" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "domain": "new-example.com",
       "protocol": "https",
       "protection_level": "standard"
     }'
Example Response
{
  "data": {
    "id": "ws_345678",
    "domain": "new-example.com",
    "protocol": "https",
    "created_at": "2023-06-10T09:45:00Z",
    "protection_level": "standard",
    "status": "active"
  }
}

SDKs & Libraries

We provide official SDKs and libraries to make it easier to integrate with the Web Defender API in your preferred programming language.

JavaScript

Our JavaScript SDK works in both Node.js and browser environments, making it easy to integrate Web Defender into your JavaScript applications.

npm install webdefender-js
View on GitHub

Python

Our Python SDK provides a simple and intuitive interface for interacting with the Web Defender API in your Python applications.

pip install webdefender
View on GitHub

PHP

Our PHP SDK makes it easy to integrate Web Defender into your PHP applications, with support for modern PHP features and frameworks.

composer require webdefender/webdefender-php
View on GitHub

Java

Our Java SDK provides a robust and type-safe interface for interacting with the Web Defender API in your Java applications.

<dependency>
  <groupId>online.webdefender</groupId>
  <artifactId>webdefender-java</artifactId>
  <version>1.0.0</version>
</dependency>
View on GitHub

Go

Our Go SDK provides a clean and idiomatic interface for interacting with the Web Defender API in your Go applications.

go get github.com/webdefender/webdefender-go
View on GitHub

Community SDKs

Our community has developed SDKs for additional languages and frameworks. These SDKs are maintained by the community but follow our best practices.

Available for: Ruby, .NET, Swift, Rust, and more.

View on GitHub

Need Help with the API?

Our developer support team is here to help you integrate Web Defender into your applications. Contact us with any questions or issues.