- OAuth
- Case Insensitive Lookups
- Pal Lookups
- Breeding Lookups
- Sickness Lookups
- Items Lookups
- Crafting Lookups
- Gear Lookups
- Food Effects Lookups
- Tech Tree Lookups
- Building Objects
- Built in docs
- Built in interface to test api calls
- Data stored in MySQL database
- Passive Skills
- NPC Lookups
- Elixir Lookups
/redoc for API docs. Can be disabled by leaving environment variable REDOC_URL blank
/docs For testing API. Can be disabled by leaving environment variable DOCS_URL blank
Note
When using OAuth all API request need to use Authorization header
-
Authorization: Bearer ACCESS-TOKEN
Reference
-
[!IMPORTANT]
When using OAuth users need theAPIUser:Readscope-
Pals
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_pals(name: str): url = "http://127.0.0.0/pals/" headers = { "Accept": "application/json", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_pals(name="lamball"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_pals(name: str, access_token: str): url = "http://127.0.0.0/pals/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( get_pals(name="lamball", access_token="kajfe0983qjaf309ajj3w8j3aij3a3") )
Parameter Type Description namestringPal name dexkeystringPaldex string. Ex. 012BtypestringPal type suitabilitystringPal work type dropstringItem skillstringPal skill nocturnalboolIf true returns night pals, false returns day pal Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
Boss Pals
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_bosspals(name: str): url = "http://127.0.0.0/bosspals/" headers = { "Accept": "application/json", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_bosspals(name="Mammorest"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_bosspals(name: str, access_token: str): url = "http://127.0.0.0/bosspals/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( get_bosspals(name="Mammorest", access_token="kajfe0983qjaf309ajj3w8j3aij3a3") )
Parameter Type Description namestringPal name typestringPal type suitabilitystringPal work type dropstringItem skillstringPal skill nocturnalboolIf true returns night pals, false returns day pal Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
Breeding
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_breeding(name: str): url = "http://127.0.0.0/breeding/" headers = { "Accept": "application/json", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_breeding(name="Anubis"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_breeding(name: str, access_token: str): url = "http://127.0.0.0/breeding/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( get_breeding(name="Anubis", access_token="kajfe0983qjaf309ajj3w8j3aij3a3") )
Parameter Type Description namestringPal you want get egg of Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
Sickness
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_sickness(name: str): url = "http://127.0.0.0/sickness/" headers = { "Accept": "application/json", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_sickness(name="ulcer"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_sickness(name: str, access_token: str): url = "http://127.0.0.0/sickness/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( get_sickness(name="ulcer", access_token="kajfe0983qjaf309ajj3w8j3aij3a3") )
Parameter Type Description namestringSickness Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
Items
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_items(name: str): url = "http://127.0.0.0/items/" headers = { "Accept": "application/json", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_items(name="arrow"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_items(name: str, access_token: str): url = "http://127.0.0.0/items/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_items(name="arrow", access_token="kajfe0983qjaf309ajj3w8j3aij3a3"))
Parameter Type Description namestringItem name typestringItem type suitabilitystringPal work type Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
Crafting
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_crafting(name: str): url = "http://127.0.0.0/crafting/" headers = { "Accept": "application/json", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_crafting(name="arrow"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_crafting(name: str, access_token: str): url = "http://127.0.0.0/crafting/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( get_crafting(name="arrow", access_token="kajfe0983qjaf309ajj3w8j3aij3a3") )
Parameter Type Description namestringItem name to get recipe info for Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
Gear
-
Curl
curl -X 'GET' \ 'http://127.0.0.0/gear/?name=cloth%20outfit&page=1&size=50' \ -H 'Accept: application/json'
curl -X 'GET' \ 'http://127.0.0.0/gear/?name=cloth%20outfit&page=1&size=50' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer kajfe0983qjaf309ajj3w8j3aij3a3'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_gear(name: str): url = "http://127.0.0.0/gear/" headers = { "Accept": "application/json", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_gear(name="cloth outfit"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_gear(name: str, access_token: str): url = "http://127.0.0.0/gear/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( get_gear(name="cloth outfit", access_token="kajfe0983qjaf309ajj3w8j3aij3a3") )
Parameter Type Description namestringGear to lookup Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
-
Foodeffect
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_foodeffect(name: str): url = "http://127.0.0.0/foodeffect/" headers = { "Accept": "application/json", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_foodeffect(name="salad"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_foodeffect(name: str, access_token: str): url = "http://127.0.0.0/foodeffect/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( get_foodeffect(name="salad", access_token="kajfe0983qjaf309ajj3w8j3aij3a3") )
Parameter Type Description namestringFood item Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
Tech
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_tech(name: str): url = "http://127.0.0.0/tech/" headers = { "Accept": "application/json", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_tech(name="Nail"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_tech(name: str, access_token: str): url = "http://127.0.0.0/tech/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_tech(name="Nail", access_token="kajfe0983qjaf309ajj3w8j3aij3a3"))
Parameter Type Description One Of namestringTech tree item levelintTech tree level Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
Build
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_build(name: str): url = "http://127.0.0.0/build/" headers = { "Accept": "application/json", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_build(name="Campfire"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_build(name: str, access_token: str): url = "http://127.0.0.0/build/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( get_build(name="Campfire", access_token="kajfe0983qjaf309ajj3w8j3aij3a3") )
Parameter Type Description One Of namestringBuilding Object categorystringTech tree level Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
Passive
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_passive(name: str): url = "http://127.0.0.0/passive/" headers = { "Accept": "application/json", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_passive(name="Brave"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_passive(name: str, access_token: str): url = "http://127.0.0.0/passive/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( get_passive(name="Brave", access_token="kajfe0983qjaf309ajj3w8j3aij3a3") )
Parameter Type Description namestringPassive skill Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
NPC
-
Curl
curl -X 'GET' \ 'http://127.0.0.0/npc/?name=Wandering%20Merchant&page=1&size=50' \ -H 'Accept: application/json'
curl -X 'GET' \ 'http://127.0.0.0/npc/?name=Wandering%20Merchant&page=1&size=50' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer kajfe0983qjaf309ajj3w8j3aij3a3'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_npc(name: str): url = "http://127.0.0.0/npc/" headers = { "Accept": "application/json", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_npc(name="Wandering Merchant"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_npc(name: str, access_token: str): url = "http://127.0.0.0/npc/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( get_npc( name="Wandering Merchant", access_token="kajfe0983qjaf309ajj3w8j3aij3a3" ) )
Parameter Type Description namestringnpc Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
-
Elixir
-
Curl
curl -X 'GET' \ 'http://127.0.0.0/elixir/?name=Speed%20Elixir&page=1&size=50' \ -H 'Accept: application/json'
curl -X 'GET' \ 'http://127.0.0.0/elixir/?name=Speed%20Elixir&page=1&size=50' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer kajfe0983qjaf309ajj3w8j3aij3a3'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_elixir(name: str): url = "http://127.0.0.0/elixir/" headers = { "Accept": "application/json", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_elixir(name="Speed Elixir"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_elixir(name: str, access_token: str): url = "http://127.0.0.0/elixir/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"name": name, "page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( get_elixir( name="Speed Elixir", access_token="kajfe0983qjaf309ajj3w8j3aij3a3" ) )
Parameter Type Description namestringElixir Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
-
All
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_all(category: str): url = f"http://127.0.0.0/all/{category}" headers = { "Accept": "application/json", } params = {"page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_all(category="pals"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_all(category: str, access_token: str): url = f"http://127.0.0.0/all/{category}" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( get_all(category="pals", access_token="kajfe0983qjaf309ajj3w8j3aij3a3") )
Category Type Description palsstringPals bosspalsstringBoss Pals itemsstringItems breedingstringBreeding buildobjectsstringBuild Objects craftingstringCrafting foodeffectstringFood Effect gearstringGear sickpalstringSickness techtreestringTech Tree passiveskillsstringPassive Skills npcstringNpc elixirstringElixir Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
Autocomplete
-
Curl
curl -X 'GET' \ 'http://127.0.0.0/autocomplete/palname/?name=la&page=1&size=50' \ -H 'Accept: application/json'
curl -X 'GET' \ 'http://127.0.0.0/autocomplete/palname/?name=la&page=1&size=50' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer kajfe0983qjaf309ajj3w8j3aij3a3'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_autocomplete(category: str, name: str): url = f"http://127.0.0.0/autocomplete/{category}" headers = { "Accept": "application/json", } params = {"name": name, "page": 1, "size": 25} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_autocomplete(category="palname", name="la"))
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_autocomplete(category: str, name: str, access_token: str): url = f"http://127.0.0.0/autocomplete/{category}" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"name": name, "page": 1, "size": 25} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( get_autocomplete( category="palname", name="la", access_token="kajfe0983qjaf309ajj3w8j3aij3a3" ) )
Category Type Description palnamestringPal name paldexkeystringPal dex string bossnamestringBoss pal name sicknessstringSickness passiveskillstringPassive skill itemnamestringItem name itemtypestringItem type craftingstringCrafting gearstringGear foodstringFood techstringTech buildnamestringBuilding object buildcategorystringBuilding category elixirstringElixir npcstringNpc Parameter: namestringStart of name of what your looking for. Optional: pageintPage number to return sizeintHow many to return per page. Default: 25Max:25 -
-
-
-
Login
[!NOTE]
Login will make any refresh token you currently have invalid.-
Curl
curl -X 'POST' \ 'http://127.0.0.0/oauth2/login/' \ -H 'Accept: application/json' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'username=Bob123&password=SomePass'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def post_login(username: str, password: str): url = f"http://127.0.0.0/oauth2/login/" headers = { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", } body = {"username": username, "password": password} try: async with aiohttp.ClientSession() as session: async with session.post(url, headers=headers, data=body) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(post_login(username="Bob123", password="SomePass"))
Category Type Description usernamestringUsername passwordstringPassword -
-
Refresh
-
Curl
curl -X 'POST' \ 'http://127.0.0.0/oauth2/refresh/' \ -H 'Accept: application/json' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'token=kafaj083209jq904j8qjiaf39&grant_type=refresh_token'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def post_refresh(refresh_token: str): url = f"http://127.0.0.0/oauth2/refresh/" headers = { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", } body = {"token": refresh_token, "grant_type": "refresh_token"} try: async with aiohttp.ClientSession() as session: async with session.post(url, headers=headers, data=body) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(post_refresh(refresh_token="kafaj083209jq904j8qjiaf39"))
Category Type Description tokenstringRefresh token grant_typestringThis needs to be set to refresh_token -
-
Validate
-
Curl
curl -X 'GET' \ 'http://127.0.0.0/oauth2/validate' \ -H 'Accept: application/json' \ -H 'Authorization: OAuth kajfe0983qjaf309ajj3w8j3aij3a3'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_user_me(access_token: str): url = "http://127.0.0.0/oauth2/validate" headers = { "Accept": "application/json", "Authorization": f"OAuth {access_token}", } try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_user_me(access_token="kajfe0983qjaf309ajj3w8j3aij3a3"))
-
-
-
-
Change Password
[!IMPORTANT]
Users need theAPIUser:Read, APIUser:ChangePasswordscopes[!NOTE]
Changing password will make any access/refresh token you currently have invalid.-
Curl
curl -X 'PUT' \ 'http://127.0.0.0/user/changepassword/' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer kajfe0983qjaf309ajj3w8j3aij3a3' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'current_password=SomePass&new_password=SomeNewPass'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def put_user_change_password( current_password: str, new_password: str, access_token: str ): url = f"http://127.0.0.0/user/changepassword/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", "Content-Type": "application/x-www-form-urlencoded", } body = {"current_password": current_password, "new_password": new_password} try: async with aiohttp.ClientSession() as session: async with session.put(url, headers=headers, data=body) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( put_user_change_password( current_password="SomePass", new_password="SomeNewPass", access_token="kajfe0983qjaf309ajj3w8j3aij3a3", ) )
Category Type Description current_passwordstringCurrent Password new_passwordstringNew Password -
-
Me
[!IMPORTANT]
Users need theAPIUser:Readscopes-
Curl
curl -X 'GET' \ 'http://127.0.0.0/user/me/' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer kajfe0983qjaf309ajj3w8j3aij3a3'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_user_me(access_token: str): url = f"http://127.0.0.0/user/me/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_user_me(access_token="kajfe0983qjaf309ajj3w8j3aij3a3"))
-
-
-
[!IMPORTANT]
Users need theAPIAdmin:Writescope-
Add User
-
Curl
curl -X 'Post' \ 'http://127.0.0.0/admin/adduser/' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer kajfe0983qjaf309ajj3w8j3aij3a3' \ -H 'Content-Type: application/json' \ -d '{ "username": "Bob123", "password": "SomePass", "scopes": [ "APIUser:Read", "APIUser:ChangePassword" ], "disabled": false }'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def post_add_user( access_token: str, username: str, password: str, scopes: list, disabled: bool ): url = f"http://127.0.0.0/admin/adduser/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", "Content-Type": "application/json", } json_body = { "username": username, "password": password, "scopes": scopes, "disabled": disabled, } try: async with aiohttp.ClientSession() as session: async with session.post(url, headers=headers, json=json_body) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( post_add_user( access_token="kajfe0983qjaf309ajj3w8j3aij3a3", username="Bob123", password="SomePass", scopes=["APIUser:Read", "APIUser:ChangePassword"], disabled=False, ) )
Category Type Description usernamestringUsername passwordstringPassword scopeslistList of scopes. Valid Scopes [APIAdmin:Write, APIUser:Read, APIUser:ChangePassword] disabledboolAccount disabled -
-
Change Password
[!NOTE] Changing password will make any access/refresh token the user currently has invalid.
-
Curl
curl -X 'PUT' \ 'http://127.0.0.0/admin/chpass/' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer kajfe0983qjaf309ajj3w8j3aij3a3' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'username=Bob123&new_password=SomeNewPass'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def put_admin_change_password( username: str, new_password: str, access_token: str ): url = f"http://127.0.0.0/admin/chpass/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", "Content-Type": "application/x-www-form-urlencoded", } body = {"username": username, "new_password": new_password} try: async with aiohttp.ClientSession() as session: async with session.put(url, headers=headers, data=body) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( put_admin_change_password( username="Bob123", new_password="SomeNewPass", access_token="kajfe0983qjaf309ajj3w8j3aij3a3", ) )
Category Type Description usernamestringUsername new_passwordstringPassword -
-
Delete User
-
Curl
curl -X 'DELETE' \ 'http://127.0.0.0/admin/deleteuser/?username=Bob123' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer kajfe0983qjaf309ajj3w8j3aij3a3'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def delete_admin_delete_user(access_token: str, username: str): url = "http://127.0.0.0/admin/deleteuser/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"username": username} try: async with aiohttp.ClientSession() as session: async with session.delete(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( delete_admin_delete_user( access_token="kajfe0983qjaf309ajj3w8j3aij3a3", username="Bob123" ) )
Category Type Description usernamestringUsername -
-
Users
-
Curl
curl -X 'GET' \ 'http://127.0.0.0/admin/users/?page=1&size=50' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer kajfe0983qjaf309ajj3w8j3aij3a3'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def get_admin_users(access_token: str): url = "http://127.0.0.0/admin/users/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", } params = {"page": 1, "size": 50} try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run(get_admin_users(access_token="kajfe0983qjaf309ajj3w8j3aij3a3"))
Category Type Description Optional: pageintPage number to return sizeintHow many to return per page. Default: 50Max:200 -
-
User Disable
-
Curl
curl -X 'PUT' \ 'http://127.0.0.0/admin/userdisable/' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer kajfe0983qjaf309ajj3w8j3aij3a3' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'username=Bob123&disabled=True'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def put_admin_user_disable(access_token: str, username: str, disabled: bool): url = f"http://127.0.0.0/admin/userdisable/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", "Content-Type": "application/x-www-form-urlencoded", } body = {"username": username, "disabled": disabled} try: async with aiohttp.ClientSession() as session: async with session.put(url, headers=headers, data=body) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( put_admin_user_disable( access_token="kajfe0983qjaf309ajj3w8j3aij3a3", username="Bob123", disabled=True, ) )
Category Type Description usernamestringUsername disabledboolAccount disabled -
-
Change Scopes
-
Curl
curl -X 'PUT' \ 'http://127.0.0.0/admin/chscope/' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer kajfe0983qjaf309ajj3w8j3aij3a3' \ -H 'Content-Type: application/json' \ -d '{ "username": "Bob123", "scopes": [ "APIUser:Read", "APIUser:ChangePassword" ], }'
-
Python
import asyncio import json import aiohttp from aiohttp.client_exceptions import ClientConnectorError async def put_admin_change_scope(access_token: str, username: str, scopes: list): url = f"http://127.0.0.0/admin/chscope/" headers = { "Accept": "application/json", "Authorization": f"Bearer {access_token}", "Content-Type": "application/json", } json_body = { "username": username, "scopes": scopes, } try: async with aiohttp.ClientSession() as session: async with session.put(url, headers=headers, json=json_body) as result: data = await result.json() except ClientConnectorError as e: print(f"ClientConnectorError: {e}") else: print(json.dumps(data, indent=2)) if __name__ == "__main__": asyncio.run( put_admin_change_scope( access_token="kajfe0983qjaf309ajj3w8j3aij3a3", username="Bob123", scopes=["APIUser:Read", "APIUser:ChangePassword"], ) )
Category Type Description usernamestringUsername scopeslistList of scopes. Valid Scopes [APIAdmin:Write, APIUser:Read, APIUser:ChangePassword] -
-
-
Extract it somewhere.
-
Edit the example.env file and rename to
.env- To make
SECRET_KEY- Linux: Run
openssl rand -hex 32. - Windows: You can use this site https://www.browserling.com/tools/random-hex and change
How many digits?to 64 then hitGenerate Hex.
- Linux: Run
- To make
-
Edit the compose.yaml file.
-
Uncomment
#ports: # - ${HTTP_PORT}:${HTTP_PORT}
-
-
If not running it behind a reversed proxy edit the Dockerfile
-
Dockerfile Edits
Uncomment this line
# CMD ["sh", "-c", "uvicorn mainapi:app --host 0.0.0.0 --port $HTTP_PORT"]
and comment this lineCMD ["sh", "-c", "uvicorn mainapi:app --host 0.0.0.0 --port $HTTP_PORT --proxy-headers --forwarded-allow-ips='*'"]
-
-
To deploy run
docker-compose upDetails
You will need your own MySQL server
-
Do steps 1 through 3 above.
-
Recommended: Setup a Python virtual environment
-
Move the
.envinto thepyPalworldAPIfolder -
Install Python requirements.
pip install -r requirements.txt
-
Import the PalAPI.sql data from the mysqldb folder into your MySQL server.
-
If not using a reverse proxy run from in the pyPalworldAPI folder.
uvicorn mainapi:app --host 0.0.0.0 --port 8000
-
With a reverse proxy run from in the pyPalworldAPI folder
uvicorn mainapi:app --host 0.0.0.0 --port 8000 --proxy-headers --forwarded-allow-ips='*'
To run this project, you will need to add the following environment variables to your .env file
DOCS_URL
REDOC_URL
HTTP_PORT
MYSQL_USER
MYSQL_PASSWORD
MYSQL_DATABASE
SQL_HOST
MYSQL_USER_DATABASE
SQL_USER_HOST
MYSQL_RANDOM_ROOT_PASSWORD
MYSQL_PORT
COMPOSE_PROFILES
SECRET_KEY
ACCESS_TOKEN_EXPIRE_MINUTES
REFRESH_TOKEN_EXPIRE_DAYS
ADMIN_NAME
This project is used by the following projects:
Distributed under the MIT License