RestFX

RestFX

A rest api library for you fxserver, to either build a rest api or interact with one or more rest apis

About

I created this resource so its easy to create a rest api for your (FiveM or RedM) server build on the CitizenFX framework. It uses a simple syntax to build a rest api, next to this we included post and fetch methods to interact with an rest api. Also the are a copple of pre built routes shipped with the resource like the /ping route for checking the server status. We also created a /tebex route to recieve http request from your tebex webstore if some made a purchage (Tebex Webhook Support).

Example

* within this example we refer to the localhost addres which is 127.0.0.1:30120

-- file: server/main.lua

-- request uri: http://localhost:30120/restfx/hi/mom
restfx.route('/hi/:to', function(request, response)

    print(req.param.to) -- prints "mom" to console

    -- change the response body
    response.body = {
        greating = "hi, child"
    }

    -- return the response to the client who requested this path 
    return response

end)

The first open source project created by @stemcmyk using the resource at scale, go check it out!

13 Likes

This looks very nice!

1 Like

can we use our ip ?

1 Like

Awesome stuff

1 Like

Holy shit I love it!

2 Likes

So nice. Thanks

2 Likes

Just add the resource to you server and simply resplace the localhost ip with the one of your server.

Remember that the port you send the request to needs to ben enabled within your firewall. If so you can make a call to your server from the outside.

The webpage you get should look like this.
api-example

So nice! Interesting release

1 Like

The fxmanifest paths are wrong in the git, so please correct it, good job anyway!

2 Likes

Thanks for letting me know i’ll change this asap. :sweat_smile:

Awesome work Sm1Ly ! :heart_eyes:

1 Like

is this ipv4 or public ip ?

and there is any get post req example with params ?

public, and no i currently have none but i’m working on a bigger project rn so it can take some time before i update the resource or giving you a good example, sorry.

thanks!

Finally got around to using this and having a play around.

Honestly, really awesome work. Hopefully your other projects are just as successful.

1 Like

Thank you very much, honestly ive not been developing for fivem lately. I’m focusing on by study and internship, next to this i’m participating in a programming contest. All this together takes about 100+ hours of my week so yea :sweat_smile:. But when i’m done maybe i’ll be back with some new stuff and next to this i once had the plan to expand the routes with a lot more and also some framework based. but its nice to see that people actually use it, so thanks again mate!