Gamebanana API for Deno
An API Wrapper for gamebanana.com
Setup
Import
Import the library using Deno
import { Client } from 'https://deno.land/x/gamebanana/mod.ts';If you want to login your app and get your API key, you can use the login method.
Client Methods
Client.login(options: ClientConfig, format?: keyof FormatTypes): Promise<string>
Validates your appās API password, App ID and user ID and returns an authentication token on success.
options: The options to use for the login. SeeClientConfigfor more information.format?: The format to use for the response. SeeFormatTypesfor more information.
var token = Client.login({
apiPassword: "<YOUR API PASSWORD>",
appId: "<YOUR APP ID>",
userId: "<YOUR USER ID>",
})
console.log(token) // -> <YOU API TOKEN>Client.Item
A class for interacting with the Item API.
Init with new Client.Item();
const item = new Client.Item();Item.data(item: ItemData | ItemData[], format?: keyof FormatTypes): Promise<string>
Get the data of an item.
item: The item to get the data of. Can be a single item or an array of items. SeeItemDatafor more information.format?: The format to use for the response. SeeFormatTypesfor more information.
item.data({
type: "Member"
id: "1832",
fields: [
"name",
"Buddies().Count().nCount()",
"Modgroup().bIsInAnyModgroup()",
"Modgroup().aModgroupsMemberIsPartOf()"
]
}); // ->
/*
[
"tom",
1580,
true,
[
"super",
"treehouse"
]
]
*/idetifyById(item: ItemByID | ItemByID[], format?: keyof FormatTypes): Promise<string>
Returns a boolean indicating if the item with the id exists.
item: The item to check the id of. Can be a single item or an array of items. SeeItemByIDfor more information.format?: The format to use for the response. SeeFormatTypesfor more information.
item.identifyById({
id: "1832"
}); // -> trueClient.List
A class for interacting with the List API.
Init with new Client.List();
const list = new Client.List(); List.like(itemType: āGameā | āMemberā, field: string, match: string, format?: keyof FormatTypes): Promise<string>
Returns submissions or entities matching the start of a field.
itemType: The type of item to search.field: The field to search.match: The string to match.format?: The format to use for the response. SeeFormatTypesfor more information.
list.like("Game", "name", "game"); // ->
/*
[
{
"id": 6408,
"name": "Game Boy"
},
{
"id": 14021,
"name": "Game Builder Garage"
},
{
"id": 7772,
"name": "Game Dev Tycoon"
},
{
"id": 7178,
"name": "Game of Thrones"
},
{
"id": 8,
"name": "GameBanana"
},
{
"id": 4981,
"name": "GameMaker"
}
]
*/List.section(itemType: keyof DataItemTypes, sort: string, direction: āascā | ādescā, page: number, format?: keyof FormatTypes): Promise<string>
Returns submission or entity IDs by section.
itemType: The type of item to search. SeeDataItemTypesfor more information.sort: The field to sort by.direction: The direction to sort by.page: The page to return.format?: The format to use for the response. SeeFormatTypesfor more information.
list.section("Game", "name", "asc", 1); // ->
/*
[
5708,
6026,
5412,
5732,
9277,
5538,
9152,
6219,
15603,
8453,
5991,
6484,
5245,
7701,
6628,
4637,
5244,
1218,
2464,
7786
]
*/List.new(settings: NewList): Promise<string>
Returns a list of new submissions or entities.
settings: The settings to use for the list. SeeNewListfor more information.
list.new({
page: 1
}); // ->
/*
[
[
"Mod",
384390
],
[
"Mod",
384389
],
[
"Mod",
384388
],
[
"Mod",
384387
],
[
"Mod",
384386
],
[
"Request",
37923
],
[
"Wip",
68404
],
[
"Request",
37922
],
[
"Mod",
384384
],
[
"Mod",
384383
],
[
"Mod",
384382
],
[
"Question",
29393
],
[
"Question",
29392
],
[
"Wip",
68403
],
[
"Question",
29391
],
[
"Mod",
384381
],
[
"Mod",
384380
],
[
"Request",
37921
],
[
"Mod",
332609
],
[
"Mod",
384379
]
]
*/Client.Member
A class for interacting with the Member API.
Init with new Client.Member();
const member = new Client.Member();Member.identify(userName: string | string[], format?: keyof FormatTypes): Promise<string>
Returns the userās ID if found, or false if not.
userName: The user name to search for. Can be a single user name or an array of user names.format?: The format to use for the response. SeeFormatTypesfor more information.
member.identify("tom"); // ->
// [ 1382 ]Member.identifyById(userId: number | number[], format?: keyof FormatTypes): Promise<string>
Returns the userās name if found, or false if not.
userId: The user id to search for. Can be a single user id or an array of user ids.format?: The format to use for the response. SeeFormatTypesfor more information.
member.identifyById(1382); // ->
// [ "tom" ]Types
FormatTypes
json: Returns the response as JSON.json_min: Returns the response as JSON, but with minimal formatting.xml: Returns the response as XML.yaml: Returns the response as YAML.php_serialized: Returns the response as a PHP serialized string.
ItemData {}
type: The type of item.id: The ID of the item.fields: The fields of the item.
ItemById {}
type: The type of item.id: The ID of the item.
DataItemTypes
Any value inside this array
[
"App",
"Article",
"ArticleCategory",
"BlogCategory",
"Bug",
"Blog",
"Club",
"Clan",
"Contest",
"Concept",
"ConceptCategory",
"ContestCategory",
"ContestWinner",
"Event",
"EventCategory",
"Forum",
"File",
"Feature",
"GeneratorCategory",
"Game",
"Generator",
"Idea",
"Initiative",
"Jam",
"JamCategory",
"Mod",
"Medal",
"ModCategory",
"Model",
"ModelCategory",
"Member",
"News",
"NewsCategory",
"Poll",
"PollCategory",
"Project",
"ProjectCategory",
"PositionAvailable",
"Question",
"QuestionCategory",
"Review",
"Request",
"RequestCategory",
"Staff",
"Script",
"ScriptCategory",
"Sound",
"SoundCategory",
"Spray",
"SprayCategory",
"Studio",
"StatusUpdate",
"Support",
"Thread",
"Tool",
"ToolCategory",
"Tutorial",
"TutorialCategory",
"Todo",
"Update",
"Wiki",
"WikiCategory",
"WareCategory",
"Wip",
"Ware",
"WareOrder",
"WipCategory"
]NewList {}
page: The page of the list to return.itemType?: The type of item to return.gameId?: GameID of submission or entity. Separate multiple IDs with commas.userId?: UserID of submission or entity.studioId?: StudioID of submission or entity.maxAge: Maximum age of submissions, in seconds.includeUpdated?: Include updated submissions.format?: The format to use for the response. SeeFormatTypesfor more information.
License
This module is licensed under the MIT license