/Game-API

english Game-api fork

Primary LanguageHTMLMIT LicenseMIT

Game-API

English game-api fork.

What happened to the real Game-api?

The creator was hacked, so I have all the control!

Mais comment ?

Link

C'est simple ! Vous aurez plusieurs exemples ici:

Obtenir tout les jeux disponibles dans l'API

GET /api/games/all

Obtenir un jeu par son identifiant

GET /api/games/(id)

Obtenir le nom d'un jeu par son identifiant

GET /api/games/(id)/name

Obtenir le créateur d'un jeu par son identifiant

GET /api/games/(id)/creators

Obtenir le type d'un jeu par son identifiant

GET /api/games/(id)/type

Obtenir la longue description d'un jeu par son identifiant

GET /api/games/(id)/long_desc

Obtenir la petite description d'un jeu par son identifiant

GET /api/games/(id)/short_desc

Exemples:

Python

import requests

r = requests.get("https://game-api.jgame.repl.co/api/games/1")
print(r)
data = r.json()
print(data['name'])

#Expected outputs: 
#{
# 'id':1,
# 'creators': 'creators',
# 'type': 'type', 
# 'name': 'name',
# 'short_desc': 'short description',
# 'long_desc': 'long description'
#}

# Asynchronous method:
import aiohttp
import asyncio

async def game_api():
   async with aiohttp.ClientSession() as session:
           url = "https://game-api.jgame.repl.co/api/games/1"
           async with session.get(url) as resp:
                       data = await resp.json()
                       print(data['name'])

asyncio.run(game_api())

Golang

package main

import (
   "io/ioutil"
   "log"
   "net/http"
)

func main() {
   resp, err := http.Get("https://game-api.jgame.repl.co/api/games/1")
   if err != nil {
      log.Fatalln(err)
   }
   body, err := ioutil.ReadAll(resp.Body) 
   if err != nil {
      log.Fatalln(err)
   }
   sb := string(body)
   log.Printf(sb)
}
/* Expected outputs:
{
 'id':1,
 'creators': 'creators',
 'type': 'type',
 'name': 'name',
 'short_desc': 'short description',
 'long_desc': 'long description'
}
*/

Javascript

const Http = new XMLHttpRequest();

const url='https://game-api.jgame.repl.co/api/games/1';

Http.open("GET", url);

Http.send();

Http.onreadystatechange = (e) => {

  console.log(Http.responseText)

}

/* Expected outputs:

{

 'id':1,

 'creators': 'creators',

 'type': 'type',

 'name': 'name',

 'short_desc': 'short description',

 'long_desc': 'long description'

}
*/