All Projects → godot-addons → godot-unirest

godot-addons / godot-unirest

Licence: MIT License
Unirest in GDScript: Simplified, lightweight HTTP client library.

Programming Languages

GDScript
375 projects

Projects that are alternatives of or similar to godot-unirest

VisualNovelKit
Combo of addons + template to create narrative games in Godot inspired by Ren'Py
Stars: ✭ 78 (+143.75%)
Mutual labels:  godot, godot-engine, godot-addon
godot-interpolated-camera3d
Provides an InterpolatedCamera3D node that replicates its 3.2.x functionality (and more)
Stars: ✭ 40 (+25%)
Mutual labels:  godot, godot-engine, godot-addon
PostgreSQLClient
PostgreSQL connector for Godot Engine in GDScript.
Stars: ✭ 28 (-12.5%)
Mutual labels:  godot, godot-engine, godot-addon
godot-logger
Simple in-game logger for Godot 4.0
Stars: ✭ 14 (-56.25%)
Mutual labels:  godot, godot-engine, godot-addon
nativelib-cli
NativeLib is a plugin management system for Godot engine.
Stars: ✭ 19 (-40.62%)
Mutual labels:  godot, godot-engine, godot-addon
godot-rpgdb
An easy to use JSON database-manager for Godot.
Stars: ✭ 25 (-21.87%)
Mutual labels:  godot, godot-engine, godot-addon
viewport-spy
Godot editor UI to spy on what a Viewport is rendering. Useful for debugging.
Stars: ✭ 28 (-12.5%)
Mutual labels:  godot, godot-engine, godot-addon
Project-Map
No description or website provided.
Stars: ✭ 52 (+62.5%)
Mutual labels:  godot, godot-engine, godot-addon
GodotTerrainEditorPainter
Heightmap based terrain editor plugin for GODOT with vertex color based terrain shader painting
Stars: ✭ 23 (-28.12%)
Mutual labels:  godot, godot-engine, godot-addon
Logic-Circuit-Simulator
A free and open-source Logic Circuit Simulator built in Godot Engine.
Stars: ✭ 23 (-28.12%)
Mutual labels:  godot, godot-engine
-godot-gj-api
GameJolt API plugin for Godot Engine
Stars: ✭ 45 (+40.63%)
Mutual labels:  godot, godot-engine
godot-lod-demo
Demonstration project for the Level of Detail (LOD) Godot 3.x add-on
Stars: ✭ 34 (+6.25%)
Mutual labels:  godot, godot-engine
godot-ci
Docker image to export Godot Engine games. Templates for Gitlab CI and GitHub Actions to deploy to GitLab Pages/GitHub Pages/Itch.io.
Stars: ✭ 316 (+887.5%)
Mutual labels:  godot, godot-engine
Freedom-Hunter
Monster Hunter like action RPG game
Stars: ✭ 71 (+121.88%)
Mutual labels:  godot, godot-engine
godot-size-benchmarks
Benchmarks to compare Godot binary sizes with different build-time options
Stars: ✭ 36 (+12.5%)
Mutual labels:  godot, godot-engine
godot-shotgun-party
An evolving multiplayer project for Godot Engine 3.
Stars: ✭ 171 (+434.38%)
Mutual labels:  godot, godot-engine
godot-uuid
Unique identifier generation v4 for Godot Engine
Stars: ✭ 96 (+200%)
Mutual labels:  godot, godot-engine
Fake-Interior-Shader-for-GodotEngine
Interior Mapping shader for the Godot Game Engine 3.x that works with both GLES3 and GLES2.
Stars: ✭ 40 (+25%)
Mutual labels:  godot, godot-engine
godot-plugin-refresher
Adds a dropdown and refresh button combo to the toolbar for instantly toggling off/on a plugin. Enables faster workflows for Godot plugin developers.
Stars: ✭ 104 (+225%)
Mutual labels:  godot, godot-engine
OpMon-Godot
An open source Pokemon-inspired game, now with Godot
Stars: ✭ 50 (+56.25%)
Mutual labels:  godot, godot-engine

Unirest for Godot Engine (v3.0)

Unirest is a set of lightweight HTTP libraries available in multiple languages, built and maintained by Mashape, who also maintain the open-source API Gateway Kong.

Features

  • Make GET, POST, PUT, PATCH, DELETE requests
  • Both syncronous and asynchronous (non-blocking) requests
  • Supports form parameters, file uploads and custom body entities
  • Supports gzip
  • Supports Basic Authentication natively
  • Customizable timeout
  • Customizable default headers for every request (DRY)
  • Automatic JSON parsing into a native object for JSON responses

Installing

To utilize Unirest, install it using asset library, or simply download and copy unirest-gdscript to your addons folder.

Creating Requests

So you're probably wondering how using Unirest makes creating requests in GDScript easier, let's start with a working example:

var unirest = preload("res://addons/unirest-gdscript/unirest.gd")
var response = unirest.post("http://httpbin.org/post", { "Accept": "application/json" }, { "parameter": 23, "foo": "bar" })

response.code # The HTTP status code
response.headers # The HTTP headers
response.body # The parsed response
response.raw_body # The unparsed response

Asynchronous Requests

GDScript also supports asynchronous requests in which you can define a callback function to be passed along and invoked when Unirest receives the response:

var unirest = preload("res://addons/unirest-gdscript/unirest.gd")

func callback_function(response):
  response.code # The HTTP status code
  response.headers # The HTTP headers
  response.body # The parsed response
  response.raw_body # The unparsed response
  
var thread = unirest.post("http://httpbin.org/post", { "Accept": "application/json" }, { "parameter": 23, "foo": "bar" }, callback_function)

Custom Entity Body

var unirest = preload("res://addons/unirest-gdscript/unirest.gd")

var response = unirest.post("http://httpbin.org/post", { "Accept": "application/json" },
  json.dumps({
    "parameter": "value",
    "foo": "bar"
  })
)

Note: For the sake of simplicity, even with custom entities in the body, the keyword argument is still params (instead of data for example). I'm looking for feedback on this.

Basic Authentication

Authenticating the request with basic authentication can be done by providing an auth array like:

var unirest = preload("res://addons/unirest-gdscript/unirest.gd")
var response = unirest.get("http://httpbin.org/get", ['username', 'password'])

Request

var unirest = preload("res://addons/unirest-gdscript/unirest.gd")

unirest.get(url, headers = {}, params = {}, auth = (), callback = None)
unirest.post(url, headers = {}, params = {}, auth = (), callback = None)
unirest.put(url, headers = {}, params = {}, auth = (), callback = None)
unirest.patch(url, headers = {}, params = {}, auth = (), callback = None)    
unirest.delete(url, headers = {}, params = {}, auth = (), callback = None)
  • url - Endpoint, address, or URI to be acted upon and requested information from in a string format.
  • headers - Request Headers as an associative array
  • params - Request Body as an associative array or object
  • auth - The Basic Authentication credentials as an array
  • callback - Asychronous callback method to be invoked upon result.

Response

Upon receiving a response, Unirest returns the result in the form of an Object. This object should always have the same keys for each language regarding to the response details.

  • code - HTTP Response Status Code (Example 200)
  • headers- HTTP Response Headers
  • body- Parsed response body where applicable, for example JSON responses are parsed to Objects / Associative Arrays.
  • raw_body- Un-parsed response body

Advanced Configuration

You can set some advanced configuration to tune Unirest-Python:

Timeout

You can set a custom timeout value (in seconds):

unirest.timeout(5) # 5s timeout

Default Request Headers

You can set default headers that will be sent on every request:

unirest.default_header('Header1','Value1')
unirest.default_header('Header2','Value2')

You can clear the default headers anytime with:

unirest.clear_default_headers()

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].