How can I download multiple files from an API quickly using HTTPResquest or is there a better way?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Anon

This is the code for my college, I am using to access youtube api and output title and thumbnail in godot using itemlist node. HTTPResquest downloading take some time before it fetches next request as a result itemlist displays nothing until the ongoing download is completed so put an “await” to next fetch next link after one second interval and this giving me required result with 1 sec delay. Is there anyway to show all titles and thumbnail at same time like it happens on youtube website, if it takes 2-3secs to load everything that’s fine too. Please help me.

var I_APIFetch =
var U_APIRequest = ""
func F_DisplayRes():
for i in range(0, db.query_result.size()):
	I_APIFetch.F_FetchTitle(db.query_result[i]["Source"], U_APIRequest, U_APIKey)
	await get_tree().create_timer(1).timeout
	U_SearchRes.add_item(I_APIFetch.API_Title, I_APIFetch.U_Thumbnail, true)

C_APIFetch class

extends Control
class_name C_APIFetch

var U_Thumbnail
var API_Title = "Blank"
var API_Thumbnail
var API_YT =
var http_request =
var J_File

func F_FetchTitle(P_Link, P_APIRequest, P_APIKey):
    var P_FetchLink = P_APIRequest + P_Link + P_APIKey

func _on_HTTPRequest_request_completed(_result, _response_code, _headers, body):
    J_File = JSON.parse_string(body.get_string_from_utf8())
    API_Title = J_File.items[0].snippet.title
    API_Thumbnail = J_File.items[0].snippet.thumbnails.medium.url

 func F_FetchThumbnail(P_Link):

 func _http_request_completed(_result, _response_code, _headers, body):
    var image =
    U_Thumbnail = ImageTexture.create_from_image(image)

Thank You

Could you create multiple instances of your HttpClient, and download them asynchronously?

SteveSmith | 2023-06-27 20:09