Skip to content

Networking Overview

What is RetroDev.Networking?

RetroDev.Networking is a simplified HTTP request library for Unity. It provides clean, callback-based methods for making GET, POST, PUT, and DELETE requests without the boilerplate of Unity’s UnityWebRequest.

Get RetroDev.Networking here:

Download Networking →

The Problem It Solves

Making HTTP requests in Unity requires a lot of boilerplate:

Before RetroDev.Networking:

IEnumerator GetData() {
using (UnityWebRequest request = UnityWebRequest.Get(url)) {
request.SetRequestHeader("Authorization", "Bearer token");
yield return request.SendWebRequest();
if (request.result == UnityWebRequest.Result.Success) {
Debug.Log(request.downloadHandler.text);
} else {
Debug.LogError(request.error);
}
}
}

With RetroDev.Networking:

QuickRequest.Get(url, headers,
response => Debug.Log(response),
error => Debug.LogError(error)
);

Key Features

Simple API

Clean, callback-based methods that don’t require coroutines or async/await.

All HTTP Methods

Support for GET, POST, PUT, and DELETE—everything you need for REST APIs.

Custom Headers

Easy header management for authentication, content types, and custom fields.

Multiple Content Types

Built-in support for JSON, form data, and raw text payloads.

Built-In Error Handling

Separate callbacks for success and failure—handle errors gracefully without try-catch blocks.

What RetroDev.Networking Provides

HTTP Methods

GET - Retrieve Data:

QuickRequest.Get(url, headers, onSuccess, onError);

POST - Send Data:

QuickRequest.Post(url, data, contentType, headers, onSuccess, onError);

PUT - Update Data:

QuickRequest.Put(url, data, headers, onSuccess, onError);

DELETE - Remove Data:

QuickRequest.Delete(url, headers, onSuccess, onError);

Content Type Support

  • contentType.Json - For JSON APIs
  • contentType.Form - For form-encoded data
  • contentType.Text - For plain text

Custom Headers

var headers = new Dictionary<string, string> {
{ "Authorization", "Bearer your_token" },
{ "User-Agent", "MyUnityGame/1.0" },
{ "Custom-Header", "value" }
};

Common Use Cases

Leaderboards:

void SubmitScore(int score) {
var data = new Dictionary<string, object> {
{ "playerName", playerName },
{ "score", score }
};
QuickRequest.Post(
"https://api.mygame.com/leaderboard",
data,
contentType.Json,
headers,
response => Debug.Log("Score submitted!"),
error => Debug.LogError("Failed: " + error)
);
}

User Authentication:

void Login(string email, string password) {
var credentials = new Dictionary<string, object> {
{ "email", email },
{ "password", password }
};
QuickRequest.Post(
"https://api.mygame.com/auth/login",
credentials,
contentType.Json,
null,
response => HandleLoginSuccess(response),
error => ShowLoginError(error)
);
}

Fetching Game Config:

void LoadGameConfig() {
QuickRequest.Get(
"https://api.mygame.com/config",
headers,
response => ApplyConfig(response),
error => UseDefaultConfig()
);
}

Saving Player Progress:

void SaveProgress(PlayerData data) {
string jsonData = JsonUtility.ToJson(data);
QuickRequest.Put(
"https://api.mygame.com/player/progress",
jsonData,
headers,
response => Debug.Log("Progress saved"),
error => Debug.LogError("Save failed: " + error)
);
}

When to Use RetroDev.Networking

Perfect for:

  • REST API integration
  • Leaderboards and analytics
  • User authentication
  • Cloud saves
  • Live config updates
  • Matchmaking services
  • Any HTTP-based backend

You might not need it if:

  • You’re using Unity’s Multiplayer services
  • You need WebSocket connections
  • You require GraphQL support
  • You’re using a game-specific networking framework

Error Handling Best Practices

Always handle both success and error cases:

QuickRequest.Get(
url,
headers,
response => {
// Success - update UI, parse data, etc.
ProcessData(response);
},
error => {
// Error - show message, retry, use cached data
Debug.LogError($"Request failed: {error}");
ShowErrorMessage("Network error, please try again");
}
);

Authentication Patterns

Bearer Token:

var headers = new Dictionary<string, string> {
{ "Authorization", $"Bearer {authToken}" }
};

API Key:

var headers = new Dictionary<string, string> {
{ "X-API-Key", apiKey }
};

Basic Auth:

string credentials = Convert.ToBase64String(
Encoding.UTF8.GetBytes($"{username}:{password}")
);
var headers = new Dictionary<string, string> {
{ "Authorization", $"Basic {credentials}" }
};

Network Availability

Always check network status before making requests:

if (Application.internetReachability == NetworkReachability.NotReachable) {
ShowOfflineMessage();
return;
}
// Make request
QuickRequest.Get(url, headers, onSuccess, onError);

Getting Started

Ready to integrate web services into your game? Check out the Quick Start guide for detailed examples of each HTTP method.