10000 GitHub - Aik-10/rest_api: An adaptable REST API built for handling HTTPS calls and doubling as a FiveM resource, simplifying multiplayer server development
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

An adaptable REST API built for handling HTTPS calls and doubling as a FiveM resource, simplifying multiplayer server development

Notifications You must be signed in to change notification settings

Aik-10/rest_api

Repository files navigation

rest_api

A FiveM remote api to control trigger events.

Configs

  • Resource configuration is handled using cfx convars.
  • Example event register script Aik-10/gists.
set api:accessToken "change_me" # Authentication string
set api:logLevel "error" # 'debug' | 'info' | 'warn' | 'error'
set api:enableCors "true"
set api:port "4290"

Usage

Custom event Register / Trigger

POST /EventHandler/{event}/{source}
Parameters
name type data type description
event required string N/A
source optional string N/A
GET arg optional string string[]
Responses
http code content-type response
200 application/json Registered event return values
400 application/json {"code":"400","status": "error","message":"Bad Request"}
401 application/json {"code":"401","status": "error","message":"Unauthorized user"}
404 application/json {"code":"404","status": "error","message":"Exception message"
Example cURL
 curl --location 'http://127.0.0.1:4290/EventHandler/test_with_args/10?arg=1' \ --header 'x-access-key: change_me'
exports.rest_api:RegisterRestApiEvent( 'test_with_args', function(source, a, b) 
   print("test_with_args", source,a,b);
   return source,a,b
end);

Run TriggerClientEvent

POST /TriggerClientEvent/{event}/{source}
Parameters
name type data type description
event required string N/A
source required string N/A
GET arg optional string string[]
Responses
http code content-type response
200 application/json TriggerClientEvent({event}, {source}) Triggered
400 application/json {"code":"400","status": "error","message":"Bad Request"}
401 application/json {"code":"401","status": "error","message":"Unauthorized user"}
404 application/json {"code":"404","status": "error","message":"Exception message"
Example cURL
 curl --location 'http://127.0.0.1:4290/TriggerClientEvent/trigger:client:test/10' \ --header 'x-access-key: change_me'

Run TriggerServerEvent

POST /TriggerServerEvent/{event}/{source}
Parameters
name type data type description
event required string N/A
source optional string N/A
GET arg optional string string[]
Responses
http code content-type response
200 application/json TriggerClientEvent({event}, {source}) Triggered
400 application/json {"code":"400","status": "error","message":"Bad Request"}
401 application/json {"code":"401","status": "error","message":"Unauthorized user"}
404 application/json {"code":"404","status": "error","message":"Exception message"
Example cURL
 curl --location 'http://127.0.0.1:4290/TriggerServerEvent/trigger:server:test' \ --header 'x-access-key: change_me'

About

An adaptable REST API built for handling HTTPS calls and doubling as a FiveM resource, simplifying multiplayer server development

Topics

Resources

Stars

Watchers

Forks

0