Created
February 15, 2022 07:12
-
-
Save KishoreKaushal/430d735413c9412ce986747579cb17a1 to your computer and use it in GitHub Desktop.
Albion Online Gameinfo API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
from urllib.parse import urlencode, urljoin, urlparse | |
from pprint import pformat | |
BASE_URL = "https://gameinfo.albiononline.com/api/gameinfo" | |
def search(query): | |
search_url = BASE_URL + "/search?{}".format(urlencode({'q': query})) | |
return requests.get(search_url).json() | |
def guild_stats(guild_id): | |
guild_url = BASE_URL + "/guilds/{}".format(guild_id) | |
return requests.get(guild_url).json() | |
def guild_members(guild_id): | |
members_url = BASE_URL + "/guilds/{}/members".format(guild_id) | |
return requests.get(members_url).json() | |
def guild_top(guild_id): | |
top_url = BASE_URL + "/guilds/{}/top".format(guild_id) | |
return requests.get(top_url).json() | |
if __name__=='__main__': | |
data = search('The Hidden Knights') | |
print(pformat(data), end='\n--------------------------------------------\n') | |
if len(data['guilds']) > 0: | |
guild_id = data['guilds'][0]['Id'] | |
print(pformat(guild_stats(guild_id)), end='\n--------------------------------------------\n') | |
print(pformat(guild_members(guild_id)[68]), end='\n--------------------------------------------\n') | |
print(pformat(guild_top(guild_id)), end='\n--------------------------------------------\n') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment