Back To Top
  • Hey Guest,
    If you are interested in ghosting, the Ghosting Awards from February 2025 all the way up to June 2025 have just been announced:

    Statement regarding the delays

    Ghosting Awards for February 2025

    Ghosting Awards for March 2025

    Ghosting Awards for April 2025

    Ghosting Awards for May 2025

    Ghosting Awards for June 2025
    Dismiss Notice
  • API Wrapper

    Discussion in 'Anything and everything Free Rider' started by Calculus, Aug 13, 2021.

    Tags:
    ?

    What do you think of this API wrapper?

    1. It's very useful!

      64.3%
    2. I couldn't find a use for it.

      35.7%
    3. I'll leave my response below. Seems neat!

      35.7%
    Multiple votes are allowed.
    1. Calculus

      Calculus Community Developer Staff Member Administrator

      Awarded Medals
      Hey everyone!

      About a year or two ago, I made an FRHD API Wrapper. When I initially made this, it was very poorly made. Over the past few days, I've been improving the methods and objects used in this to make it easier for the consumer to use. There are certain methods in this API wrapper, that which, only admin's can use. However, it's there with good reason. For example; there's one method created specifically for something Totoca12 and I have been working on. That is the removal of all cheated ghosts. No average user can use this method, however, it is accessible to everyone. This project, as just about all my projects are, is open source. Check it out if you wish.

      Functions
      • getHome
      • getTrackLeaderboard
      • getPlayerLeaderboard
      • getAuthorLeaderboard
      • getCategory
      • getUser
      • getTrack
        • getLeaderboard
        • getComment
        • getRace
      • getComment
      • getRandom
      • getRace
      • getFeatruedGhosts
      Client Methods
      • login
      • getUser
        • addFriend
        • removeFriend
        • subscribe
        • unsubscribe
        • setUsername - ADMINISTRATIVE USE ONLY
        • setEmail - ADMINISTRATIVE USE ONLY
        • toggleOA - ADMINISTRATIVE USE ONLY
        • ban - ADMINISTRATIVE USE ONLY
      • getTrack
        • getLeaderboard
        • getComment
          • reply
          • delete
        • postComment - REQUIRES LOGIN
          • reply
          • delete
        • deleteComment - REQUIRES LOGIN
        • sendChallenge - REQUIRES LOGIN
        • vote - REQUIRES LOGIN
        • getRace
        • removeRace - ADMINISTRATIVE USE ONLY
        • addDaily - ADMINISTRATIVE USE ONLY
        • hide - ADMINISTRATIVE USE ONLY
      • postTrack - REQUIRES LOGIN
      • getNotifications - REQUIRES LOGIN
      • changeUsername - REQUIRES LOGIN
      • changeDescription - REQUIRES LOGIN
      • changePassword - REQUIRES LOGIN
      • setForumPassword - REQUIRES LOGIN
      • buyHead - REQUIRES LOGIN
      • setHead - REQUIRES LOGIN
      • addFriend - REQUIRES LOGIN
      • acceptFriend - REQUIRES LOGIN
      • removeFriend - REQUIRES LOGIN
      • subscribe - REQUIRES LOGIN
      • unsubscribe - REQUIRES LOGIN
      • removeRace - ADMINISTRATIVE USE ONLY
      • addDailyTrack - ADMINISTRATIVE USE ONLY
      • hideTrack - ADMINISTRATIVE USE ONLY
      • deepClean - ADMINISTRATIVE USE ONLY
      • setUsername - ADMINISTRATIVE USE ONLY
      • setEmail - ADMINISTRATIVE USE ONLY
      • toggleOA - ADMINISTRATIVE USE ONLY
      • banUser - ADMINISTRATIVE USE ONLY
      • redeemCoupon - REQUIRES LOGIN
      • logout
      Proper documentation:
      https://github.com/Calculamatrise/frhd/wiki
      https://calculamatrise.github.io/frhd/api/docs/ - Deprecated

      Source code:
      https://github.com/Calculamatrise/frhd
      https://github.com/Calculamatrise/frpy
       
      Last edited: Aug 30, 2023
    2. Calculus

      Calculus Community Developer Staff Member Administrator

      Awarded Medals
      I guess it would be helpful if I added a list of methods and functions. That being said, I'll edit the main post shortly.

      Edit: I reckon I'll add a page to my site with all features given I can better customize it so it would be easier for the consumer to use. I guess I'm making documentation of sorts.
       
      Blank_Guy, Fluoride and FIREBEATS like this.
    3. Calculus

      Calculus Community Developer Staff Member Administrator

      Awarded Medals
      Also, if anyone would like to see an addition to this; if there's a feature I missed out on, let me know and I'll be sure to add it ASAP.
       
      Fluoride and FIREBEATS like this.
    4. AfterImage

      AfterImage Well-Known Member Team Balloon Official Author

      Awarded Medals
      Im confused again how do you use this?
       
      josephhd likes this.
    5. HATEYOU

      HATEYOU Well-Known Member Official Author

      no idea what this wrapper can do but i like the idea to give some power to totoca
       
      josephhd likes this.
    6. Calculus

      Calculus Community Developer Staff Member Administrator

      Awarded Medals
      It's made for people who have a fair bit of experience in JavaScript. This won't be useful to everyone.
       
      Fluoride and josephhd like this.
    7. Calculus

      Calculus Community Developer Staff Member Administrator

      Awarded Medals
      Perhaps we gave him too much power as he was banned for, I'm assuming, abusing powers. Which just isn't right. He was doing FRHD a favor by removing all the cheated ghosts.
       
      Fluoride and RubeGoldberger like this.
    8. revelcw

      revelcw Member Official Author

      I understand all of the code, but what's the deal with abusing powers?
       
      FIREBEATS likes this.
    9. Calculus

      Calculus Community Developer Staff Member Administrator

      Awarded Medals
      It's all cleared up. I assume Brett thought Totoca12 was abusing his powers via the Client#deepClean method. So, he was banned. The ban has since been lifted.
       
    10. Calculus

      Calculus Community Developer Staff Member Administrator

      Awarded Medals
      Release - Version 0.0.1

      A few changes (I won't list them all):
      - Client#getUser
      Code:
      client.getUser("Guest")
              .then(function(uesr) {
                      console.log(user);
              });
      
      + UserManager#fetch
      + UserManagerCache#get
      Code:
      client.users.fetch("Guest")
              .then(function(uesr) {
                      console.log(user);
              });
      
      let user = client.users.cache.get("Guest");
      console.log(user);
      
      The same applies to tracks and notifications.

      Thanks, y'all!
       
      Last edited: Oct 28, 2021
      Fluoride and FIREBEATS like this.
    11. isekeb

      isekeb Well-Known Member Team Blob Official Author

      I'm almost 100% sure he was automatically banned for exceeding a request limit. the deepClean method makes 835350*(userCount+1) requests with only a few milliseconds of delay, which I don't think FRHD allows

      also, you hardcode the last track's ID here, but fetching the recently-added endpoint and getting the ID of the first element would allow the script to check every listed track in the database
       
      Fluoride, josephhd, Calculus and 2 others like this.
    12. Calculus

      Calculus Community Developer Staff Member Administrator

      Awarded Medals
      I wouldn't be so sure. Otherwise, wouldn't the cheaters get banned as well when they initially cheated on the 700,000+ tracks or so? Also, it waits for each request to return a response before moving on to the next; hence, there's no set time that it would take. But I estimate around 2 * (userCount) + 1 requests per second and a half.
       
      Fluoride and FIREBEATS like this.
    13. FIREBEATS

      FIREBEATS FRHD Member of 2020 Team Helicopter Official Author

      Your soooooo smart
       
    14. Calculus

      Calculus Community Developer Staff Member Administrator

      Awarded Medals
      I wish I could say the same; You're*
       
    15. Calculus

      Calculus Community Developer Staff Member Administrator

      Awarded Medals
      Furthermore, over the past few weeks, I've made somewhere around half a million requests. As you can see:
      upload_2021-8-22_19-40-3.png

      Totoca12 only went through about 150,000 tracks. Which would have been around 400,000 requests. As we speak, I'm making requests as I am attempting to like every track on the database aside from hidden tracks.

      I rest my case.
       
    16. Calculus

      Calculus Community Developer Staff Member Administrator

      Awarded Medals
      Thanks, all has been taken into consideration and I've modified the method:
      Code:
         async deepClean({ users, startingTrackId = 1001, endingTrackId, timeout = 0 } = {}, callback = response => response) {
              if (!token)
                  throw new Error("INVALID_TOKEN");
      
              if (!endingTrackId)
                  endingTrackId = await getCategory("recently-added").then(function(response) {
                      return parseInt(response.tracks[0].slug);
                  });
            
              users = await Promise.all(users.map(async user => {
                  if (user.match(/\D+/gi)) {
                      user = await this.users.fetch(user);
                      if (!user)
                          throw new Error("INVALID_USER");
      
                      return user.id;
                  }
      
                  return parseInt(user);
              }));
      
              for (let trackId = startingTrackId; trackId <= endingTrackId; trackId++) {
                  await this.tracks.fetch(trackId).then(async function(track) {
                      if (users) {
                          for (const userId of users) {
                              track.removeRace(userId);
                          }
                      } else {
                          await track.getLeaderboard().then(leaderboard => {
                              for (const race of leaderboard) {
                                  if (race && typeof race.runTime !== "undefined" && !race.runTime) {
                                      track.removeRace(race.userId || race.user.id);
                                  }
                              }
                          });
                      }
      
                      return track.id;
                  }).then(callback);
                  await new Promise(resolve => setTimeout(resolve, timeout, resolve));
              }
          }
      
       
    17. SilentFinger

      SilentFinger I have 3 featured tracks Elite Author Official Author

      Awarded Medals
    18. Calculus

      Calculus Community Developer Staff Member Administrator

      Awarded Medals
      I figured as much.
       
      Overthrown and Fluoride like this.
    19. SilentFinger

      SilentFinger I have 3 featured tracks Elite Author Official Author

      Awarded Medals
      I'm glad you think so highly of my intellect
       
      Overthrown and Fluoride like this.
    20. Calculus

      Calculus Community Developer Staff Member Administrator

      Awarded Medals
      I think highly of everyone until they do something stupid.
       

    Share This Page