blocky/2 JSON API

Overview:

GET
/api/activity
Displays the current activity entries

JSON parameters:


Response examples:

200:
{}
default:
{
    "code": 403,
    "reason": "You need to be logged in to view this endpoint!"
}
DELETE
/api/bans
Remove a whitelist entry

JSON parameters:

force: (boolean) Force addition, even if it means removing conflicting rules already in the DB
reason: (string) The reason for banning
rule: (string) the ID of an existing rule
source: (string) the source IP Address or Network
target: (string) Target machine to ban on (or * for all machines)
timeout: (integer) If present and greater than 0, denotes the UNIX timestamp when this rule stops working

Input examples:

application/json:
{}

Response examples:

200:
{
    "message": "Action completed"
}
default:
{
    "code": 403,
    "reason": "You need to be logged in to view this endpoint!"
}
GET
/api/bans
Displays the current banlistr entries

JSON parameters:


Response examples:

200:
{}
default:
{
    "code": 403,
    "reason": "You need to be logged in to view this endpoint!"
}
PUT
/api/bans
Add a banmlist entry

JSON parameters:

force: (boolean) Force addition, even if it means removing conflicting rules already in the DB
reason: (string) The reason for banning
rule: (string) the ID of an existing rule
source: (string) the source IP Address or Network
target: (string) Target machine to ban on (or * for all machines)
timeout: (integer) If present and greater than 0, denotes the UNIX timestamp when this rule stops working

Input examples:

application/json:
{}

Response examples:

200:
{
    "message": "Action completed"
}
default:
{
    "code": 403,
    "reason": "You need to be logged in to view this endpoint!"
}
PUT
/api/myrules
Set a host's iptables list

JSON parameters:


Input examples:

application/json:
{
    "iptables": [
        {
            "action": "DROP",
            "chain": "INPUT",
            "destination": "1.2.3.4",
            "extensions": "/* comment here */",
            "linenumber": 26,
            "option": "comment",
            "protocol": "tcp",
            "source": "1.2.3.4"
        }
    ]
}

Response examples:

200:
{
    "message": "Action completed"
}
default:
{
    "code": 403,
    "reason": "You need to be logged in to view this endpoint!"
}
DELETE
/api/rules
Remove a rule entry

JSON parameters:

limit: (integer) The limit that causes a ban
name: (string) The name of the rule
query: (array) The individual query args to look for
rid: (string) rule ID, if overriding a previous rule
span: (integer) The span (in hours) within which to look for offenses
type: (string) The type of rule

Input examples:

application/json:
{}

Response examples:

200:
{
    "message": "Action completed"
}
default:
{
    "code": 403,
    "reason": "You need to be logged in to view this endpoint!"
}
GET
/api/rules
Displays the current ruleset entries

JSON parameters:


Response examples:

200:
{}
default:
{
    "code": 403,
    "reason": "You need to be logged in to view this endpoint!"
}
PUT
/api/rules
Adds or overrides a ruleset

JSON parameters:

limit: (integer) The limit that causes a ban
name: (string) The name of the rule
query: (array) The individual query args to look for
rid: (string) rule ID, if overriding a previous rule
span: (integer) The span (in hours) within which to look for offenses
type: (string) The type of rule

Input examples:

application/json:
{}

Response examples:

200:
{
    "message": "Action completed"
}
default:
{
    "code": 403,
    "reason": "You need to be logged in to view this endpoint!"
}
POST
/api/search
Search for whether an IP or block is banned or whitelisted

JSON parameters:

source: (string) IP Address or Network to search for

Input examples:

application/json:
{}

Response examples:

200:
{}
default:
{
    "code": 403,
    "reason": "You need to be logged in to view this endpoint!"
}
DELETE
/api/whitelist
Remove a whitelist entry

JSON parameters:

force: (boolean) Force addition, even if it means removing conflicting rules already in the DB
reason: (string) The reason for banning
rule: (string) the ID of an existing rule
source: (string) the source IP Address or Network
target: (string) Target machine to ban on (or * for all machines)
timeout: (integer) If present and greater than 0, denotes the UNIX timestamp when this rule stops working

Input examples:

application/json:
{}

Response examples:

200:
{
    "message": "Action completed"
}
default:
{
    "code": 403,
    "reason": "You need to be logged in to view this endpoint!"
}
GET
/api/whitelist
Displays the current whitelist entries

JSON parameters:


Response examples:

200:
{}
default:
{
    "code": 403,
    "reason": "You need to be logged in to view this endpoint!"
}
PUT
/api/whitelist
Add a whitelist entry

JSON parameters:

force: (boolean) Force addition, even if it means removing conflicting rules already in the DB
reason: (string) The reason for banning
rule: (string) the ID of an existing rule
source: (string) the source IP Address or Network
target: (string) Target machine to ban on (or * for all machines)
timeout: (integer) If present and greater than 0, denotes the UNIX timestamp when this rule stops working

Input examples:

application/json:
{}

Response examples:

200:
{
    "message": "Action completed"
}
default:
{
    "code": 403,
    "reason": "You need to be logged in to view this endpoint!"
}