- Contributors
- faketuna, Rily_
- Supported Skript Version
- 2.7
- Supported Minecraft Versions
- 1.13
- 1.14
- 1.15
- 1.16
- 1.17
- 1.18
- 1.19
- 1.20
About support:
If you have any requests, bug reports, or just want help from me. Please create Issue on GitHub.
I will not provide support in any platform except GitHub.
Addon in alpha:
This Addon is in alpha, so cause probrems please use at your own risk.
Also this addon is includes missing features and functions, because created for my personal usage.
Features:
Note:
This plugin requires paper server or paper based server.
Requirements:
Installing:
Same as other common addons.
Example and syntax has provided in Skript Hub.
Important:
If you use reply effect in not end of event you need exit after reply for avoid error
You should respond the HTTP request otherwise HTTP clients keep waiting for your response.
Example:
Example script in skunity is may be outdated when the plugin update.
Latest Example script is can be found in here.
Todo:
Todo is found in my github readme.
Contributors:
Rily_: Wrote the addon icon.
If you have any requests, bug reports, or just want help from me. Please create Issue on GitHub.
I will not provide support in any platform except GitHub.
Addon in alpha:
This Addon is in alpha, so cause probrems please use at your own risk.
Also this addon is includes missing features and functions, because created for my personal usage.
Features:
- Simple HTTP Server
- Send web request
Note:
This plugin requires paper server or paper based server.
Requirements:
- Paper server or paper based server
- Version 1.13
Installing:
Same as other common addons.
- Download latest SkriptWebAPI-<Version>.jar from here.
- Put your downloaded jar to server plugins folder
- Run and ready to use
Example and syntax has provided in Skript Hub.
Important:
If you use reply effect in not end of event you need exit after reply for avoid error
code_language.skript:
if (something):
reply %httpexchange% with %string% and response code 200
exit
if (something2):
reply %httpexchange% with %string% and response code 202
exit
code_language.skript:
on receive get request:
set {_request} to event-request
if (something):
reply {_request} with %string% and response code 200
exit
reply {_request} with %string% and response code 500
Example:
Example script in skunity is may be outdated when the plugin update.
Latest Example script is can be found in here.
code_language.skript:
# Example written in v0.1.0
on script load:
start http server in port 9000 with context "/"
on script unload:
stop http server
# ===============================
# Synced web request feature. (This may cause lag spike. If you don't want to happen, please use async web request feature.)
# ===============================
command get:
trigger:
set {_request} to new http request with method "GET"
set {_request}'s target url to "https://httpbin.org/get"
set {_request}'s header "Custom" to "Test"
set {_request}'s header "Content-Type" to "application/json"
set {_request}'s header "User-Agent" to "SkriptWebAPI/0.1.0"
set {_response} to response of {_request}
set {_body} to body of {_response}
broadcast "server: %{_response}'s header value from key "server"%"
broadcast "Body: %{_body}%"
broadcast "Status code: %status code of {_response}%"
broadcast "Request method: %request method of {_response}%"
command delete:
trigger:
set {_request} to new http request with method "DELETE"
set {_request}'s target url to "https://httpbin.org/delete"
set {_request}'s header "Custom" to "Test"
set {_request}'s header "Content-Type" to "application/json"
set {_request}'s header "User-Agent" to "SkriptWebAPI/0.1.0"
set {_response} to response of {_request}
set {_body} to body of {_response}
broadcast "server: %{_response}'s header value from key "server"%"
broadcast "Body: %{_body}%"
broadcast "Status code: %status code of {_response}%"
broadcast "Request method: %request method of {_response}%"
command patch:
trigger:
set {_request} to new http request with method "PATCH"
set {_request}'s target url to "https://httpbin.org/patch"
set {_request}'s header "Custom" to "Test"
set {_request}'s header "Content-Type" to "application/json"
set {_request}'s header "User-Agent" to "SkriptWebAPI/0.1.0"
set {_request}'s body to "{""json"":""test""}"
set {_response} to response of {_request}
set {_body} to body of {_response}
broadcast "server: %{_response}'s header value from key "server"%"
broadcast "Body: %{_body}%"
broadcast "Status code: %status code of {_response}%"
broadcast "Request method: %request method of {_response}%"
command post:
trigger:
set {_request} to new http request with method "POST"
set {_request}'s target url to "https://httpbin.org/post"
set {_request}'s header "Custom" to "Test"
set {_request}'s header "Content-Type" to "application/json"
set {_request}'s header "User-Agent" to "SkriptWebAPI/0.1.0"
set {_request}'s body to "{""json"":""test""}"
set {_response} to response of {_request}
set {_body} to body of {_response}
broadcast "server: %{_response}'s header value from key "server"%"
broadcast "Body: %{_body}%"
broadcast "Status code: %status code of {_response}%"
broadcast "Request method: %request method of {_response}%"
command put:
trigger:
set {_request} to new http request with method "PUT"
set {_request}'s target url to "https://httpbin.org/put"
set {_request}'s header "Custom" to "Test"
set {_request}'s header "Content-Type" to "application/json"
set {_request}'s header "User-Agent" to "SkriptWebAPI/0.1.0"
set {_request}'s body to "{""json"":""test""}"
set {_response} to response of {_request}
set {_body} to body of {_response}
broadcast "server: %{_response}'s header value from key "server"%"
broadcast "Body: %{_body}%"
broadcast "Status code: %status code of {_response}%"
broadcast "Request method: %request method of {_response}%"
command custom-method:
trigger:
set {_request} to new http request with method "CUSTOM"
set {_request}'s target url to "https://domain"
set {_request}'s header "Custom" to "Test"
set {_request}'s header "Content-Type" to "application/json"
set {_request}'s header "User-Agent" to "SkriptWebAPI/0.1.0"
set {_request}'s body to "{""json"":""test""}"
set {_response} to response of {_request}
set {_body} to body of {_response}
broadcast "server: %{_response}'s header value from key "server"%"
broadcast "Body: %{_body}%"
broadcast "Status code: %status code of {_response}%"
broadcast "Request method: %request method of {_response}%"
# ===============================
# Async web request feature.
# ===============================
command asyncget:
trigger:
set {_request} to new http request with method "GET"
set {_request}'s target url to "https://httpbin.org/get"
set {_request}'s header "Custom" to "Test"
set {_request}'s header "Content-Type" to "application/json"
set {_request}'s header "User-Agent" to "SkriptWebAPI/0.1.0"
send async web request with {_request}
command asyncdelete:
trigger:
set {_request} to new http request with method "DELETE"
set {_request}'s target url to "https://httpbin.org/delete"
set {_request}'s header "Custom" to "Test"
set {_request}'s header "Content-Type" to "application/json"
set {_request}'s header "User-Agent" to "SkriptWebAPI/0.1.0"
send async web request with {_request}
command asyncpatch:
trigger:
set {_request} to new http request with method "PATCH"
set {_request}'s target url to "https://httpbin.org/patch"
set {_request}'s header "Custom" to "Test"
set {_request}'s header "Content-Type" to "application/json"
set {_request}'s header "User-Agent" to "SkriptWebAPI/0.1.0"
set {_request}'s body to "{""json"":""test""}"
send async web request with {_request}
command asyncpost:
trigger:
set {_request} to new http request with method "POST"
set {_request}'s target url to "https://httpbin.org/post"
set {_request}'s header "Custom" to "Test"
set {_request}'s header "Content-Type" to "application/json"
set {_request}'s header "User-Agent" to "SkriptWebAPI/0.1.0"
set {_request}'s body to "{""json"":""test""}"
send async web request with {_request}
command asyncput:
trigger:
set {_request} to new http request with method "PUT"
set {_request}'s target url to "https://httpbin.org/put"
set {_request}'s header "Custom" to "Test"
set {_request}'s header "Content-Type" to "application/json"
set {_request}'s header "User-Agent" to "SkriptWebAPI/0.1.0"
set {_request}'s body to "{""json"":""test""}"
send async web request with {_request}
on web request response:
set {_response} to event-httpresponse
set {_body} to body of {_response}
set {_method} to request method of {_response}
broadcast "server: %{_response}'s header value from key "server"%"
broadcast "1: %{_body}%"
broadcast "2: %status code of {_response}%"
broadcast "3: %request method of {_response}%"
# ===============================
# Http server feature.
# ===============================
on http request received:
set {_request} to event-httpexchange
set {_method} to http request method of {_request}
set {_body} to http request body of {_request}
set {_userAgent} to http request {_request} request header value from key "User-Agent"
set {_path} to http request context path of {_request}
broadcast "HTTP REQUEST!"
broadcast "METHOD: %{_method}%"
broadcast "BDOY: %{_body}%"
broadcast "UA: %{_userAgent}%"
broadcast "Context: %{_path}%"
set http response {_request}'s header "Custom" to "Custom header"
set http response {_request}'s header "Invisible" to "This header should not be visible because will be deleted after set."
remove http response {_request}'s header "Invisible"
set {_returnBody} to ""
if {_method} is "DELETE":
set {_returnBody} to "{""method"":""DELETE""}"
if {_method} is "GET":
set {_returnBody} to "{""method"":""GET""}"
if {_method} is "PATCH":
set {_returnBody} to "{""method"":""PATCH""}"
if {_method} is "POST":
set {_returnBody} to "{""method"":""POST""}"
if {_method} is "PUT":
set {_returnBody} to "{""method"":""PUT""}"
broadcast "RETURN BODY: %{_returnBody}%"
if {_returnBody} is not "":
reply {_request} with body {_returnBody} and response code 200
else:
# This will reply 500 without body
reply {_request}
command testreq <string> <string>:
trigger:
set {_request} to new http request with method arg-1
set {_request}'s target url to arg-2
set {_request}'s header "Custom" to "Test"
set {_request}'s header "Content-Type" to "application/json"
set {_request}'s header "User-Agent" to "SkriptWebAPI/0.1.0"
set {_request}'s body to "{""json"":""test""}"
send async web request with {_request}
Todo:
Todo is found in my github readme.
Contributors:
Rily_: Wrote the addon icon.