Contents

Introduction

Welcome to the official N&M Games API documentation!

This documentation explains how the API can be used by you, and in which ways.

When a term from N&M Games is being used, it is often put into a hyperlink (like this) to it's Wiki page, giving a further explanation.

Happy reading and coding!

Fetching

Fetching user information

Fetching user information is an often used and easy way to receive information about N&M Gamers.

The player must have set their profile page to public in order to make the API grant their data.

Code

Sending the request

  • with cURL: curl https://api.nm-games.eu/player/:who
  • with Python Requests: requests.get("https://api.nm-games.eu/player/:who").json()
  • with XMLHttpRequest: XMLHttpRequest.open("GET", "https://api.nm-games.eu/player/:who")
  • in your browser: https://api.nm-games.eu/player/:who

:who should be replaced by the user ID or username.

Response

If everything went correctly, the API responds the following information (in JSON format):

  • error: false when no errors occured, otherwise an error description (string/boolean).
  • id: The user ID of the given player (number).
  • name: The username of the given player (string).
  • followers: The amount of followers this player has (number).
  • following: The amount of gamers this player follows (number).
  • gets_newsletter: Shows whether the player receives newsletters by mail (boolean).
  • is_admin: Shows whether the player is an admin (boolean).
  • is_banned: Shows whether the player is currently banned (boolean).
  • last_seen: Last time the player signed in (Unix format in seconds) (number).
  • registered_on: Time when the player signed up (Unix format in seconds) (number).
  • has_banner: Shows whether the player currently uses a banner (boolean).
  • has_profile_picture: Shows whether the player currently uses a profile picture (boolean).
  • discord_configurated: Shows whether the player linked his account to the Discord Server (boolean).
  • story: Information related to the player's story at the moment of fetching (object):
    • has_story: Shows if the player posted a story (boolean).
    • The following story properties only appear if one is posted:
    • text: The text of the story. Note that wildcards, mentions and styles are not changed (string).
    • post_time: Unix timestamp in seconds when the story has been posted (number).
    • edit_time: Unix timestamp in seconds when the story has been edited. null if not edited (number/null).
    • image: Shows if the player included an image with the story (boolean).
    • views: Amount of signed in gamers who have seen the story (number).
    • likes: Amount of gamers who have liked the story (number).
    • dislikes: Amount of gamers who have disliked the story (number).
  • status: The player's status information (object):
    • text: The text of the status. null if no status is set (string/null).
    • expires: Unix timestamp in seconds when the status is about to disappear. null if no status is set or the status does not expire (number/null).
  • medals: The player's medal statistics (object):
    • bronze: The amount of bronze medals the player owns (number).
    • silver: The amount of silver medals the player owns (number).
    • gold: The amount of gold medals the player owns (number).
    • games_earned_in: The amount of different games the player earned all their medals in (number).
  • game_stats: The player's game statistics (object):
    • plays: The amount of games the gamer has played in total (number).
    • fist_vs_feet: Statistics for Fist vs. Feet (object):
      • level: The player's Fist vs. Feet level (number).
      • coins: The player's Fist vs. Feet coin amount (number).
      • wins: The player's Fist vs. Feet match win count (number).
      • assists: The user ID of the player who is being assisted. null if they assist nobody (number/null).
      • current_armor: The armor items the player currently wears (object):
        • helmet: The item name of the helmet the player wears. null if they have no helmet equipped (string/null).
        • chest: The item name of the chestplate the player wears. null if they have no chestplate equipped (string/null).
      • current_loadout: The weapon names of the player's current loadout (array):
        • 0: The weapon name of the 1st weapon slot. null if no weapon is present (string/null).
        • 1: The weapon name of the 2nd weapon slot. null if no weapon is present (string/null).
        • 2: The weapon name of the 3rd weapon slot. null if no weapon is present (string/null).
      • cosmetics_owned: The amount of cosmetics the player owns (number).
    • robot_robber: Statistics for Robot Robber (object):
      • level: The current level of the player (number).
      • completed: Shows whether the player has completed the last level (boolean).
      • plus_completed: Shows whether the player has completed the plus level with all the money (boolean).
    • destroids: Statistics for Destroids (object):
      • level: The current level of the player (number).
      • cleared: The total amount of asteroids destroyed by the player (number).
      • completed: Shows whether the player has completed the last level (boolean).
    • card_collector_wins: The amount of Card Collector wins of the player (number).
    • fist_fuss_wins: The amount of Fist Fuss wins of the player (number).
    • split_or_steal: Statistics for Split or Steal (object):
      • medals_stolen: The total amount of medals the player has stolen (number).
      • parts_collected: The total amount of Medal Parts the player collected (number).
    • fisty_bird_finishes: Amount of times the player made the Fisty Bird finish (number).

Fetching game information

Next to users, game information can be fetched as well.

Code

Sending the request

  • with cURL: curl https://api.nm-games.eu/game/:id
  • with Python Requests: requests.get("https://api.nm-games.eu/game/:id").json()
  • with XMLHttpRequest: XMLHttpRequest.open("GET", "https://api.nm-games.eu/game/:id")
  • in your browser: https://api.nm-games.eu/game/:id

:id should be replaced by the game ID.

Response

If everything went correctly, the API responds the following information (in JSON format):

  • error: false when no errors occured, otherwise an error description (string/boolean).
  • name: The game name (string).
  • description: The game description (string).
  • played: Amount of times the game has been played (number).
  • collection: The collection name the game belongs to. null if not linked to one (string/null).
  • build_year: The year when the game has been released (number).
  • medals_earnable: The amount of medals that can be earned in this game (number).
  • released: Shows whether the game is playable and not under maintenance (boolean).

Fetching post information

Used to fetch information about the posts made by a user.

Public profiles are also required for the API to display post information.

Code

Sending the request

  • with cURL: curl https://api.nm-games.eu/post/:id
  • with Python Requests: requests.get("https://api.nm-games.eu/post/:id").json()
  • with XMLHttpRequest: XMLHttpRequest.open("GET", "https://api.nm-games.eu/post/:id")
  • in your browser: https://api.nm-games.eu/post/:id

:id should be replaced by the game ID.

Response

If everything went correctly, the API responds the following information (in JSON format):

  • error: false when no errors occured, otherwise an error description (string/boolean).
  • text: The text of the post. Note that mentions and styles are not changed (string).
  • views: Amount of signed in gamers who have seen the post (number).
  • hearts: Amount of gamers who have reacted with a heart on the post (number).
  • laughs: Amount of gamers who have reacted with a laugh on the post (number).
  • dislikes: Amount of gamers who have reacted with a dislike on the post (number).
  • post_time: Unix timestamp in seconds when the post has been posted (number).
  • edit_time: Unix timestamp in seconds when the post has been edited. null if not edited (number/null).

Fetching general information

Gamers and users aside, there is some general information about N&M Games available as well.

Code

Sending the request

  • with cURL: curl https://api.nm-games.eu/general
  • with Python Requests: requests.get("https://api.nm-games.eu/general").json()
  • with XMLHttpRequest: XMLHttpRequest.open("GET", "https://api.nm-games.eu/general")
  • in your browser: https://api.nm-games.eu/general

Response

If everything went correctly, the API responds the following information (in JSON format):

  • error: Always outputs false, since no errors can occur here (boolean).
  • release_dates: Information about release dates (object):
    • nm_games: Unix timestamp in seconds of the N&M Games release date (number).
    • api: Unix timestamp in seconds of the N&M Games API release date (number).
  • gamers: Numerical information about gamers (object):
    • total: Total amount of gamers who signed up (number).
    • total_visible: Total amount of gamers who have a public profile (number).
    • total_activated: Total amount of gamers who have activated their account (number).
    • total_discord_linked: Total amount of gamers who linked their account to the Discord Server.
    • currently_banned: Total amount of gamers who are banned at the moment of fetching.
  • stories: Numerical information about stories (object):
    • total_posted: Total amount of stories posted in N&M Games history (number).
    • currently_posted: Total amount of stories posted at the moment of fetching (number).
    • currently_posted_with_image: Total amount of stories posted at the moment of fetching, including an image (number).
  • total_posts: Total amount of posts made in N&M Games history (number).
  • wikis: Total amount of wiki pages available at the moment of fetching (number).

Access keys

The following feature can be used to fetch more data of N&M Gamers, and can also be used to create stories and change settings.

Generating an access key

Access keys can be generated in the Developer Settings. When creating one, you must specify for what purposes it should be used and when it should expire.

Fetching more information

Used to fetch more privacy sensitive information about players, which is not visible normally.

Code

Sending the request

  • with cURL: curl https://api.nm-games.eu/:token
  • with Python Requests: requests.get("https://api.nm-games.eu/:token").json()
  • with XMLHttpRequest: XMLHttpRequest.open("GET", "https://api.nm-games.eu/:token")
  • in your browser: https://api.nm-games.eu/:token

:token should be replaced by the access token.

Response

If everything went correctly, the API responds the following information (in JSON format):

  • error: Always outputs false, since no errors can occur here (boolean).
  • discord_name: The player's Discord username if linked with the Discord Server (string/null).
  • email_address: The player's email address where all N&M Games mails are sent to (string).
  • medals: A more detailed overview of the player's medals (object):
    • The object keys are the game IDs, the values are the amount of medals earned in that game.
  • followers: A list of the user IDs of the player's followers (array).
  • following: A list of the user IDs who the player follows (array).

Create stories

Access keys can also perform interactions with the website, creating stories for example:

Not only the key, also the player must have the rights to make a story!

Code

Sending the request

  • with cURL: curl https://api.nm-games.eu/:token/story/text=:text
  • with Python Requests: requests.get("https://api.nm-games.eu/:token/story/text=:text").json()
  • with XMLHttpRequest: XMLHttpRequest.open("GET", "https://api.nm-games.eu/:token/story/text=:text")
  • in your browser: https://api.nm-games.eu/:token/story/text=:text

:token should be replaced by the access token and :text by the story text.

Response

If everything went correctly, the API responds the following information (in JSON format):

  • error: false if no errors occured, an error description otherwise (string/boolean).
  • posted: Shows whether the story is posted successfully (boolean).

Delete stories

Stories can also be deleted with an access key.

Code

Sending the request

  • with cURL: curl https://api.nm-games.eu/:token/story/delete
  • with Python Requests: requests.get("https://api.nm-games.eu/:token/story/delete").json()
  • with XMLHttpRequest: XMLHttpRequest.open("GET", "https://api.nm-games.eu/:token/story/delete")
  • in your browser: https://api.nm-games.eu/:token/story/delete

:token should be replaced by the access token.

Response

If everything went correctly, the API responds the following information (in JSON format):

  • error: false if all privileges and data are correct, an error description otherwise (string/boolean).
  • deleted: Shows whether the story is deleted successfully (boolean).

Change account settings

Access keys can also (un)check the checkboxes in your account menu.

Code

Sending the request

  • with cURL: curl https://api.nm-games.eu/:token/settings/:setting/:value
  • with Python Requests: requests.get("https://api.nm-games.eu/:token/settings/:setting/:value").json()
  • with XMLHttpRequest: XMLHttpRequest.open("GET", "https://api.nm-games.eu/:token/settings/:setting/:value")
  • in your browser: https://api.nm-games.eu/:token/settings/:setting/:value

:token should be replaced by the access token, :setting with the setting you want to change and :value with it's value. Settings that can be changed this way and their values are:

  • profile: Change profile visibility to public or private.
  • newsletter: Change newsletter receive setting to on or off.
  • 2fa: Change Two-Factor Authentication visibility to on or off.
  • chat: Change chat privacy setting to everyone, following or admins.

Response

If everything went correctly, the API responds the following information (in JSON format):

  • error: false if no errors occured, an error description otherwise (string/boolean).
  • setting_changed: Shows whether the desired setting has been changed successfully (boolean).

Self-destruct the key

Behold! The Access Key-Inator! Technically, you could say that, since access keys can be self-destructed if you want.

Code

Sending the request

  • with cURL: curl https://api.nm-games.eu/:token/self-destruct
  • with Python Requests: requests.get("https://api.nm-games.eu/:token/self-destruct").json()
  • with XMLHttpRequest: XMLHttpRequest.open("GET", "https://api.nm-games.eu/:token/self-destruct")
  • in your browser: https://api.nm-games.eu/:token/self-destruct

:token should be replaced by the access token.

Response

If everything went correctly, the API responds the following information (in JSON format):

  • error: false if no errors occured, an error description otherwise (string/boolean).
  • self_destructed: Shows whether the access key has been deleted successfully (boolean).

NMAuth

NMAuth is an authentication protocol which can be used to verify on external websites that an N&M Games account belongs to someone.

Create an NMAuth app

An NMAuth app can be added in the Developer Settings. When creating one, you have to specify:

  • An app name, up to 25 characters, displayed to users when they are about to sign in;
  • A redirect URL where users get redirected to after signing in. The wildcard %t must be specified to identify who signed in.

Display the login window

Code

To be able to set up NMAuth apps on your website, you have to load the NMAuth JavaScript file by inserting the following line of code in your HTML file:

<script src="https://nm-games.eu/nmauth-js"></script>

Then, you can add a button to open a popup window to allow users to sign in with N&M Games, for example:

<button onclick="NMAuth(:appID)">Sign in with N&M Games</button>

:appID should be replaced by the app ID. That can be found in the first column of the NMAuth apps table in Developer Settings.

Signing in with the app

A website with an NMAuth app should contain a button like shown above, clearly displaying that it can let you sign in with N&M Games.

  • When clicking that button, a popup window should open, asking you to sign in as usual;
  • If Two-Factor Authentication is enabled, you need a 6-digit code from your mail;
  • After successfully signing in, you will be asked to authorize the app. When clicking [Deny], the process will be aborted and nothing else will happen. When clicking [Allow], you will be redirected to the redirect URL of the app, giving it a token with the possibility for the website to get your public profile data with the API, as described above.

Validate the user

When a user signed in at an app, they get redirected to the URL you specified when creating the NMAuth app, along with a success token. This token is required when creating an app, because it is needed to validate the user.

Code

Sending the request

  • with cURL: curl https://api.nm-games.eu/nmauth/:secret/:token
  • with Python Requests: requests.get("https://api.nm-games.eu/nmauth/:secret/:token").json()
  • with XMLHttpRequest: XMLHttpRequest.open("GET", "https://api.nm-games.eu/nmauth/:secret/:token")
  • in your browser: https://api.nm-games.eu/nmauth/:secret/:token

:secret should be replaced by the app secret, found in the third column of the NMAuth apps table in Developer Settings. :token should be replaced by the success token which should be found in the URL.

Response

If everything went correctly, the API responds the following information (in JSON format):

  • error: false if no errors occured, an error description otherwise (string/boolean).
  • app_id: The app ID, found in the first column of the NMAuth apps table in Developer Settings (number).
  • user: The information about the user who has been verified (object):
    • id: The user ID of the verified player (number).
    • name: The username of the verified player (string).
    • email: The email address of the verified player (string).
    • status: The current status of the verified player, null if no status is set (string/null).
    • banned: Tells whether the verified player is currently banned (boolean).

Status codes

When using the API, two different HTTP status codes can be returned along with the data:

  • 200 if a request has been sent correctly and data is sent back;
  • 404 if a request has not been sent correctly. The error property contains an error description.