[go: up one dir, main page]

Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.
/ tf2api Public archive

A web API for parsing the Team Fortress 2 wiki and getting relevant information from it.

License

Notifications You must be signed in to change notification settings

Infinixius/tf2api

Repository files navigation

ARCHIVED: I don't feel like actively working on this anymore. I might pick it up later if I think it serves any use, but feel free to fork it and continue working on it if you wish.

tf2api

A web API for parsing the Team Fortress 2 wiki and getting relevant information from it.

A version is hosted at https://tf2api.herokuapp.com. Keep in mind this is hosted on Heroku's free tier, and may not always be up.

This is just a project I made when I was bored overseas. It shouldn't really be used for anything serious, but hopefully someday someone may find it useful.

Installation

You're going to need any version of Node.js higher than 14, along with NPM (which should come with node anyway.)

If you have git already, you can run git clone https://github.com/infinixius/tf2api to get a local copy of the code. If you don't, you can use the "Download Code" button.

Finally, run npm install where the repository is to install all the NPM modules needed.

Rename config.template.json to config.json. This is used for configuring the server and an explanation can be found docs/Config.md or at https://infinixius.github.io/tf2api/Config.

Reference

Errors

Any non 204/200 response code should come a helpful error code and message:

{
	"code": "MISSINGARG",
	"message": "You need to provide a weapon name."
}

A list of all possible error codes is provided below:

  • NOTFOUND - Returned with any 404 Not Found response code.
  • WIKINOTFOUND - Returned if a page doesn't exist on the wiki. Always returns a 404 Not Found response code.
  • MISSINGARG - Missing any number of arguments. Always returns a 400 Bad Request response code.
  • BADARG - An argument or multiple arguments passed were invalid. Always returns a 400 Bad Request response code.
  • ENDPOINTDISABLED - Returned if the endpoint in question is disabled or otherwise unavailable. Always returns a 501 Not Implemented response code.
  • INTERNALERROR - Returned upon any internal server error. Always returns a 500 Internal Sever Error response code.
  • WIKIERROR - Returned if the request to the TF2 wiki failed. Always returns a 502 Bad Gateway error.

/getWeapon

Takes a weapon name and searches the wiki for it, returning the result as a JSON object.

{
    url: url,
    name: string,
    content: string,
    image: url,
    stats: [
        ["POSITIVE", string],
        ["NEGATIVE", string],
        ["NEUTRAL", string]
    ],
    release: string,
    availability: string
    
}

Example: https://tf2api.herokuapp.com/getWeapon/Phlogistinator

Planned endpoints

About

A web API for parsing the Team Fortress 2 wiki and getting relevant information from it.

Topics

Resources

License

Stars

Watchers

Forks