-
-
Notifications
You must be signed in to change notification settings - Fork 10
Developer Rest Reference
Welcome to the Developer quick reference for the Universal Api Mod essentially a DayZ Wrapper for the Universal Api Webservice this is my attempt to make a Universal Api Backend for the server hosters, allowing for a robust, easy to use and set up backend. and for modders an easy to use API wrapper to help them make hived and cross-server mods more easily. With the mod and API I handle authentication and client tokens allowing you to ensure that the data you are accessing and using is secured, preventing rouge and unwanted access to the APIs.
The Database is broken into 3 Parts to organize and protect data Globals, Objects, Players
This is the allows you to save Global Mod data to the MongoDB backend Simple usage is UApi().Rest().GlobalsSave(ModName, JSONString)
void UApi().Rest().GlobalsSave(string mod, string jsonString, ref RestCallback UCBX = NULL)
This allows you to load global data from database, simple usage is UApi().Rest().GlobalsLoad( ModName, ref ConfigHolderClass)
where your ConfigHolderClass extends RestCallback it is recommended on the server side to also pass the default config's json so that way if the Global doesn't exist it will create the default config for the player. See the Sample Config Wiki Page
void UApi().Rest().GlobalsLoad(string mod, ref RestCallback UCBX, string jsonString = "{}")
This allows you to increment an element within the database safely without having to worry about if another server or instance of the object will override your value. This will also return the new value total value back to you.
void UApi().Rest().GlobalsTransaction(string mod, string element, float value = 1, ref RestCallback UCBX = NULL)
This allows you to update an element with a new value without having to worry about override other changes other servers or instances might be making as a similar time.
void UApi().Rest().GlobalsUpdate(string mod, string guid, string element, string value, ref RestCallback UCBX = NULL)
This is the allows you to save player data to the MongoDB backend Simple usage is UApi().Rest().PlayerSave(ModName, GUID, JSONString)
void UApi().Rest().PlayerSave(string mod, string guid, string jsonString, ref RestCallback UCBX = NULL)
This allows you to load the player data from database, simple usage is UApi().Rest().PlayerLoad( ModName, GUID, ref ConfigHolderClass)
where your ConfigHolderClass extends RestCallback it is recommended on the server side to also pass the default config's json so that way if the player doesn't exist it will create the default config for the player. See the (Sample config class)[https://github.com/daemonforge/DayZ-UniveralApi/wiki/Developer-Reference---Sample-Config]
void UApi().Rest().PlayerLoad(string mod, string guid, ref RestCallback UCBX, string jsonString = "{}")
This Lets you query the Player Data See the Query wiki page for more information
void UApi().Rest().PlayerQuery(string mod, UApiQueryObject query, ref RestCallback UCBX)
This allows you to increment an element within the database safely without having to worry about if another server or instance of the object will override your value.
void UApi().Rest().PlayerTransaction(string mod, string guid, string element, float value = 1, ref RestCallback UCBX = NULL)
void UApi().Rest().PlayerUpdate(string mod, string guid, string element, string value, ref RestCallback UCBX = NULL)
This is the allows you to save Object data to the MongoDB backend Simple usage is UApi().Rest().ObjectSave(ModName, itemId, JSONString)
this endpoint also has the option to pass NewObject
as the ID and it will return a randomly generated ID back to you (Time and Random Based) It will return it in a string variable in your object called "ObjectId"
void UApi().Rest().ObjectSave(string mod, string itemId, string jsonString, ref RestCallback UCBX = NULL)
This allows you to load Object data to the MongoDB backend Simple usage is UApi().Rest().ObjectLoad(ModName, itemId, ref ConfigHolderClass)
where your ConfigHolderClass extends RestCallback it is recommended on the server-side to also pass the default config's JSON so that way if the Global doesn't exist it will create the default config for the player. This endpoint also has the option to pass NewObject
as the ID and it will return a randomly generated ID back to you (Time and Random Based) It will return it in a string variable in your object called "ObjectId"
void UApi().Rest().ObjectLoad(string mod, string itemId, ref RestCallback UCBX, string jsonString = "{}")
This allows you to query Object Data, See the Query wiki page for more information
void UApi().Rest().ObjectQuery(string mod, UApiQueryObject query, ref RestCallback UCBX)
This allows you to increment an element within the database safely without having to worry about if another server or instance of the object will override your value.
void UApi().Rest().ObjectTransaction(string mod, string objectId, string element, float value = 1, ref RestCallback UCBX = NULL)
void UApi().Rest().ObjectUpdate(string mod, string guid, string element, string value, ref RestCallback UCBX = NULL)
This is a simple prebuilt API call for discord webhooks simple usage is just UApi().DiscordMessage( webhookUrl, message)
will send a message to the discord webhook for you
void UApi().DiscordMessage(string webhookUrl, string message, string botName = "", string botAvatarUrl = "")
More documentation to come but this will allow more complex discord messages with embeds to be sent will put more information on this function at a laterdate but in the mean time if you wish to use this reference the UApiDiscordObject Class
void UApi().DiscordObject(string webhookUrl, UApiDiscordObject discordObject)
Return true if the auth token is valid Useful to make sure the API is online and the player has received their Authtoken from the server.
bool UApi().HasValidAuth()
This returns DayZPlayer Object based on the GUID lots of mods use this just thought it would be useful to include
DayZPlayer UApi().FindPlayer(string GUID)
This will return the Base Url of the Configed Universal web service Really should have no use to the average modder only useful if writing fully custom Api Requests the backend
string UApi().Rest().BaseUrl()
This returns the AuthToken for the client or server depending on where it is called Really should have no use to the average modder only useful if writing fully custom Api Requests the backend
string UApi().GetAuthToken()
This is pretty much just a prepackaged function to make simple rest calls with JSON Header
void UApi().Rest().Post(string url, string jsonString = "{}", ref RestCallback UCBX = NULL)
This is just something I'm playing with maybe helpful this must be set up on the API Server with qnamaker.ai
void UApi().QnA(string question, bool alwaysAnswer = true, ref RestCallback UCBX = NULL, string jsonString = "{}")