Resource icon
  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Supported Minecraft Versions
  1. 1.7
  2. 1.8
  3. 1.9
  4. 1.10
  5. 1.11
Pronounced /ˈɹɛkən/, like "reckon".

Reqn is an HTTP request library for Skript 2.X.

Documentation/Source - Releases

Quickstart
code_language.skript:
# Send a get request to a url. The protocol (http or https) is required.
send a request to "http://example.com"

# Send a request using a different HTTP method.
send a "put" request to "http://example.com"

# Send a request with headers and a body. They are both optional.
send a "post" request to "http://example.com" with the headers "Authorization: Token", and "Content-Type: application/json" and the body "{""body"":""don't forget to escape your quotes!""}"

# They can be in any order, too.
send a "post" request to "http://example.com" with the body "{""body"":""don't forget to escape your quotes!""}" and the headers "Authorization: Token", and "Content-Type: application/json"

# Access the last response.
set {_resp} to the last http response

# Access the response code
set {_code} to {_resp}'s status code

# Access the headers of a response.
set {_headers::*} to {_resp}'s headers

# Or just a specific header. Capitalization matters with header names.
set {_length} to {_resp}'s "Content-Length" header

# Access the body of a response.
set {_body} to {_resp}'s body

More features (such as JSON escaping) and additional syntax can be found in the documentation.

FAQ
Will requests cause my server to freeze?
No. Unlike skQuery's text from url, processing is done on a separate thread. This also delays the event, meaning you can't set event values after making a request.

Will last HTTP response change if multiple requests complete at the same time?
As long as you retrieve the last HTTP response immediately after making the request (without waiting), there is no chance of responses being mixed up. It's good practice to save the response to a variable immediately and using the variable instead if you intend on using the last HTTP response.

Can I accept compressed content?
Yes. Content compressed with GZIP or DEFLATE will be properly decompressed. Be sure to add "Accept-Encoding: gzip" to the request header to notify the web server that you are accepting compressed content.

How do I handle JSON output from a Web API?
The addon skript-json was written specifically for this purpose. It converts JSON structures into plain Skript list variables for easy consumption. As an added bonus, skript-json will convert list variables into JSON if you need to send JSON to a Web API.
Author
btk5h
Downloads
6,395
Views
6,395
First release
Last update
Rating
5.00 star(s) 2 ratings

More resources from btk5h

Latest updates

  1. Reqn 1.2.1

    Fix an issue with code after requests not being executed on the main thread Send requests as UTF-8
  2. Reqn v1.2.0

    Changelog The header syntax is now optionally singular, which should make the request syntax...

Latest reviews

Awesome addon, and awesome developer, can you add a proxy support? (This is very need, for use api with limits)
Great, lots of complex features! Would recommend :)