Download

Making a REST API Server

I’ve been looking around trying to figure this out but I can’t seem to find a solution. I want to make it so the “server” of my game has a web service that can be called RESTfully and return back json results of whatever I want.

My game(s) are built using blueprints so I was hoping there was a way with blueprints?

I have found a few resources but one of them is not finished it seems and the other is for making REST calls not serving them.

I found VaRest at VaRest in Code Plugins - UE Marketplace which is the one that helps you make REST calls and UWS at http://isaratech.com/uws which doesn’t seem to be finished yet and wont be free after it is :frowning:

I am wanting to make something that will be open source and free.

So my questions are:

  • Can this be done purely in blueprints?
  • If yes then how? A resource, documentation, tutorial or anything would be great.
  • If no then can I make it possible by creating some type of plugin?

I am assuming yes to the last question but my c++ skills are minimal so I’m really hoping for a purely blueprint solution :stuck_out_tongue: IF I have to write some c++ what are some good resources for making a plugin and adding blueprint functionality?

Sorry for the long post but I’ve wanted to do this for some time and haven’t been able to find a solution.

Varest has been popular for a while for this but it will still require you to either implement the functionality in unreal yourself or use a server side langauge of you’re choice to do it . Most popular used to be php but nowadays a lot of people are using other alternatives such as node.js for example

https://www.codementor.io/olatundega…utes-q0sgsfhbd

https://forums.unrealengine.com/deve…-json-responce

There are other plugins available that offer the same functionality just search marketplace for mysql etc and you will find them.

I have personally been using gamesparks as my backend solution for a while now and it is amazing and i think very underrated. but again requires knowledge of java as cloud code is mainly java .

Unreal already has built in json classes so if you use c++ you can again do it this way .

Unfortunately RESTFULL api and database stuff isnt an easy subject so you either have to use one of the plugins provided or do it yourself .

This is still the opposite of what I am looking for :stuck_out_tongue: tools like Varest are used for MAKING requests to RESTful servers and that subject seems to have lots of solutions. What I am looking for is a way to SERVE RESTful requests to things MAKING those requests to the server.

That UWS tool looks like it will do that but like I said it doesn’t look finished and it looks like its not going to be free/opensource so I won’t be able to contribute to it.

The basic idea is that I would like to be able to give a website the ability to query my game server and get information about it.

Think about it like this. I am wanting to add functionality like RCON but doing it in a RESTful way. So things can request lets say a list of users and it gives back a json array of users. Instead of like RCON which responds back with a plain string of users.

You will not be able to do this in blueprint. You will need to create a plugin, or modify an existing plugin to do this. You can use the one below as a guide but be advised - this HTTP server plugin is created for Unreal Tournament. I have been able to recompile it for Unreal Engine just by removing the UT stuff and commenting out appropriate lines in C++. But you will need to understand C++ to make changes to it and expand it to your own needs. Also be advised that there is zero security implemented for this, and you will also need to design your own methods for communicating from worker thread to main game thread.

Ignore that last part. It runs on a timer loop in the main thread, not in a worker thread. It’s been a while since I looked at it and I ended up not using it at all. Other things you can look into are ways of embedding a node server into a c++ project, or maybe a WCF listener. Again things that I researched but never did anything with. Good luck!

Thanks! I will look at that when I get home tonight. Working with c++ will be annoying but I am a pretty avid developer so I should be able to figure it out.

Found this just now: GitHub - ncsoft/Unreal.js: Unreal.js: Javascript runtime built for UnrealEngine 4

Heading home to see if it will do what I want :smiley: