Advertisement
Kekulator

Developer API Tutorial

Aug 25th, 2017
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.64 KB | None | 0 0
  1. Welcome to this tutorial about how to use the Developer API Module to fit your purposes!
  2.  
  3. -- PREPARING FOR YOUR GAME --
  4.  
  5. So, to start off with this Developer API, you just need to do some easy steps.
  6.  
  7. First off, we'd like to require the module.
  8.  
  9. Do so by typing this into your code : "local devAPI = require(993003470)" (without the quotation marks).
  10.  
  11. That was easy, wasn't it?
  12.  
  13. Now, if this is your first time, please note that once you make your place ready, it will only show your username and password once.
  14.  
  15. Notes away and your code should now look similar to this:
  16.  
  17. "local devAPI = require(993003470)
  18.  
  19. devAPI:Initiate()
  20.  
  21. "
  22.  
  23. Make two variables. Username and Password in your script and assign them with the Username and password in the output.
  24.  
  25.  
  26. ------------------------------
  27.  
  28. You have now prepared the server for your game data.
  29. You can now continue to any of the steps below!
  30.  
  31.  
  32. -- SAVING AND GETTING DATA --
  33.  
  34. You need to save data before you can retrieve it, otherwise it will return an error.
  35.  
  36. To save data you will need to use the ":SaveAsync()" method.
  37.  
  38. It requires 3 arguments to be provided: Username, Password, Table .
  39.  
  40. Like this : "
  41.  
  42. local Username = "xxxxxx"
  43. local Password = "XXXXXXXXXXXXX"
  44. local saveData = devAPI:SaveAsync(Username, Password, Table)
  45.  
  46. "
  47. This will return a table with information.
  48. It will return "status", "info".
  49.  
  50. You need to make security measures, so your script won't break if anything happens.
  51.  
  52. You should do:
  53.  
  54. "
  55.  
  56. local Username = "xxxxxx"
  57. local Password = "XXXXXXXXXXXXX"
  58. local saveData = devAPI:SaveAsync(Username, Password, Table)
  59.  
  60. if saveData["status"] == "success" then --If the saving was a success
  61.  
  62. print'Saving data was a success'
  63.  
  64. else --If it wasn't a success
  65.  
  66. print("Status : ", saveData["status"] , " | Info: ", saveData["info"])
  67.  
  68. end
  69.  
  70. "
  71.  
  72.  
  73. Now you have secured your code.
  74.  
  75. -Getting data-
  76.  
  77. To get the data you stored you will use the method ":GetAsync()";
  78.  
  79. It requires 2 arguments: Username, Password
  80.  
  81. It will return a table with : "status", "info", "data"
  82.  
  83. "data" contains the data you saved.
  84.  
  85. To use it:
  86.  
  87. "
  88. local Username = "xxxxxx"
  89. local Password = "XXXXXXXXXXXXX"
  90. local fetchData = devAPI:GetAsync(Username, Password)
  91.  
  92. if fetchData["status"] == "success" and fetchData["data"] ~= nil then
  93.  
  94. print'Retrieving data was a success"
  95.  
  96. local YOURDATA = fetchData["data"]
  97.  
  98. else
  99.  
  100. print("Status: ", fetchData["status"], " | Info: ", fetchData["info"] )
  101.  
  102.  
  103. end
  104.  
  105. "
  106.  
  107. Now, you know how to save and get data!
  108.  
  109. Congratulations!
  110.  
  111. ----------------------------------------------
  112.  
  113.  
  114. Below here are some functions for you as a developer who needs the Roblox API for your game.
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121. -- Getting roblox group information --
  122.  
  123. To return a table with information about a group you will use the ":GetGroupInfo()"
  124.  
  125. It requires one argument, two are optional.
  126.  
  127. The first argument is the group id.
  128. This is a string or integer.
  129.  
  130. The second argument is optional and is if you want it to return a decoded version table, otherwise it will return a JSON Encoded table.
  131. This is a bool
  132.  
  133. The third argument is depending on the second argument to be "true", this argument is if you want the script to just return the value of the name you set (i.e "Name" will return the name of the group).
  134. This is a string
  135.  
  136. Example :
  137.  
  138. "
  139. local Username = "xxxxxx"
  140. local Password = "XXXXXXXXXXXXX"
  141. local groupInfo = devAPI:GetGroupInfo("2", true, "Name")
  142.  
  143. print(groupInfo)
  144. --> "LOL"
  145.  
  146. "
  147. Now you know that, moving on to the next step ..
  148.  
  149.  
  150. -------------------------------------------
  151.  
  152.  
  153. -- Checking if two users are friends --
  154.  
  155. If you ever wondered if two users are friends or not, then this function is handy for you.
  156.  
  157. You use this function like this ":IsFriends()"
  158.  
  159. It requires 2 arguments, the user id of user1 and the user id of user 2.
  160.  
  161. This will return a bool (true / false)
  162.  
  163. Note that if you try to see if user1 is friends with user1 it will return true.
  164.  
  165. Example :
  166.  
  167. "
  168. local Username = "xxxxxx"
  169. local Password = "XXXXXXXXXXXXX"
  170. local friends = devAPI:IsFriends("1", "1")
  171.  
  172. printt(friends)
  173.  
  174. if friends then
  175. print' They are friends !!'
  176.  
  177. else
  178.  
  179. print' They are not friends :( '
  180.  
  181. end
  182.  
  183. "
  184.  
  185. Nice, you have come far, still more to go...
  186.  
  187.  
  188. -----------------------------------------
  189.  
  190.  
  191. -- Get name from user id --
  192.  
  193. This function might be handy sometimes, who knows??
  194.  
  195. You use it by doing ":NameFromId()"
  196. It requires 1 argument, and 1 is optional.
  197.  
  198. First argument is the user id.
  199.  
  200.  
  201. The second argument is optional, and is a bool if you want it to just print the username, or return a regular table with a bit more info.
  202.  
  203. Example:
  204.  
  205. "
  206. local Username = "xxxxxx"
  207. local Password = "XXXXXXXXXXXXX"
  208. local getName = devAPI:NameFromId("18442032", true)
  209.  
  210. print(getName)
  211.  
  212. --> Kekulator
  213.  
  214. "
  215.  
  216. Soon, you know all them' secrets..
  217.  
  218. ----------------------------------------------
  219.  
  220.  
  221.  
  222. --Getting the id from the name --
  223.  
  224. Well, this also might be handy sometimes in the future, and no one still knows..
  225.  
  226. To use this do ":IdFromName()"
  227.  
  228. It requires 1 argument, 1 is optional.
  229.  
  230. First argument is the username.
  231.  
  232. Second argument is if you want it just to return the user id.
  233.  
  234. Example :
  235.  
  236. "
  237.  
  238. local Username = "xxxxxx"
  239. local Password = "XXXXXXXXXXXXX"
  240. local getID = devAPI:IdFromName("Kekulator", true)
  241.  
  242. print(getID)
  243.  
  244. -->18442032
  245.  
  246. "
  247.  
  248. Coming far, I can tell..
  249.  
  250.  
  251. ---------------------------------------------
  252.  
  253.  
  254. -- Getting a user's friends --
  255.  
  256. Well, hope you enjoy!!
  257.  
  258. To use this, you need to do ":GetUserFriends()"
  259.  
  260. It requires 1 argument and 1 is optional
  261.  
  262.  
  263. The first argument is the id of the user
  264.  
  265. The second argument is optional, and returns the page you want.
  266.  
  267. Each page is a new user btw.
  268.  
  269.  
  270. Example : "
  271.  
  272.  
  273. local Username = "xxxxxx"
  274. local Password = "XXXXXXXXXXXXX"
  275. local getFriends = devAPI:GetUserFriends("18442032", 15)
  276.  
  277. print(getFriends["Username"])
  278.  
  279. --> CaptainXafius
  280.  
  281. "
  282.  
  283.  
  284. Soon TM reaching the end I guess, hope you like it so far..
  285.  
  286.  
  287.  
  288. --------------------------------------------------------------
  289.  
  290.  
  291.  
  292. This is the last function (yet) in the developer API.
  293.  
  294. -- Custom API --
  295.  
  296. To use this, you need to go to "http://api.roblox.com/docs#" and find the info you need there.
  297.  
  298. Afterwards you need to call the ":CustomAPI()"
  299.  
  300. It requires 1 argument: The link (i.e "users/USERID/friends")
  301.  
  302. NOTE THIS ONLY SUPPORTS "GET" METHODS!
  303.  
  304. Example :
  305.  
  306. "
  307.  
  308. local Username = "xxxxxx"
  309. local Password = "XXXXXXXXXXXXX"
  310. local customone = devAPI:CustomAPI("/users/USERID")
  311.  
  312. print(customone)
  313.  
  314. --Returns a JSON Encoded table, what you do with it is up to you.
  315.  
  316. "
  317. The end.
  318.  
  319.  
  320.  
  321.  
  322. JK.
  323. ------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement