Is it possible to download GitHub files directly from GDScript

Godot Version

v4.3.stable.official [77dcf97d8]

Question

Hello everyone,

I’m currently working on a Godot project (v4.3) and I’m wondering if it’s possible to download files directly from a GitHub repository using GDScript. My goal is to dynamically fetch and use these files within my project. Specifically, I will not be downloading images but rather short text files that need to be downloaded one time only from a public directory. Is there a way to achieve this? If so, could someone provide guidance or examples of how to implement this functionality?

Any help or pointers would be greatly appreciated. Thanks in advance!

You can use an HTTPRequest node for that. The documentation has an example on how to download a png file. You can use it to download whatever you need for github by using the correct URL.

For example to download the README.md file from the godot’s repo it would be something like:

extends Node

const URL = "https://raw.githubusercontent.com/godotengine/godot/refs/heads/master/README.md"

@onready var http_request: HTTPRequest = $HTTPRequest

func _ready() -> void:
	http_request.request_completed.connect(_on_request_completed)
	
	http_request.request(URL)
	
	
func _on_request_completed(result:int, response_code:int, headers:PackedStringArray, body:PackedByteArray) -> void:
	if response_code == 200:
		print(body.get_string_from_utf8())
1 Like