-
Notifications
You must be signed in to change notification settings - Fork 0
Custom API requests
Simón Olivo (Sarturo) edited this page Aug 3, 2020
·
7 revisions
In addition to the available functions, you can build your own GameJolt API request. You only need to know the endpoint and the necessary parameters. Remember that by default, the "game_id" parameter is already included in the request.
create_request(endpoint: String, params: Dictionary, options: Dictionary) -> GameJoltAPIRequest
Make a custom request to the GameJolt API
The path where you receive a resource or perform an action/feature provided by the GameJolt API.
The necessary parameters will depend on the service or resource to be requested.
-
'ssl': bool (optional) If SSL is enabled (set to
true
), API requests are made by using the HTTPS protocol. (Enabled by default).
-
api_request_completed(data: Array) Returns an array which include the following Dictionary element:
-
success: bool It will return
true
if the response is received and processed successfully. - [data]: Array The name of [data] and its existence will depend on the GameJolt API response. Depending on the API response it may contain an empty array, or contain an array with more than one Dictionary element.
-
success: bool It will return
- api_request_failed(error: String) Returns an error message.
#Sets data in the data store. Check the official documentation: https://gamejolt.com/game-api/doc/data-store/set
var set_data_request = GameJoltAPI.create_request("/data-store/set/", {
"key": "game_engine",
"data": "godot"
})
#Connect to the GameJoltAPIRequest signals
set_data_request.connect("api_request_completed", self, "_on_set_data_request_completed")
set_data_request.connect("api_request_completed", self, "_on_set_data_request_failed")
#Handle the signals
func _on_set_data_request_completed(data: Array):
#The server sent back an array containing the following element:[{'success':true}]
pass
func _on_fetch_trophies_failed(error: String):
#If an error occurs this function will be called
pass