API Setup

StreamNFT can be integrated with any programming tech stack using our API server. This allows you to interact with StreamNFT directly from your Unity application.

Creating Unity Web Requests

You can create Unity web requests using the following method:

private IEnumerator SendRequest(string url, string method, object requestData)
    string requestDataJson = JsonUtility.ToJson(requestData);

    using (UnityWebRequest request = new UnityWebRequest(url, method))
        byte[] bodyRaw = System.Text.Encoding.UTF8.GetBytes(requestDataJson);
        request.uploadHandler = new UploadHandlerRaw(bodyRaw);
        request.downloadHandler = new DownloadHandlerBuffer();
        request.SetRequestHeader("Content-Type", "application/json");

        yield return request.SendWebRequest();

        if (request.result != UnityWebRequest.Result.Success)
            Debug.LogError($"Request failed: {request.error}");
            Debug.Log($"Request successful: {request.downloadHandler.text}");

This method sends a web request to the specified URL using the provided HTTP method (e.g., GET, POST) and requests data. The request data is converted to a JSON string and sent as the body of the request.

Return Codes

The SendRequest the method returns the following HTTP status codes:

  • 200: The request was successful.

  • 500: There was an error processing the request.

Last updated