Skip to main content

Client for the PCGamingWiki API

Project description

pcgw_api: Python client for the PCGamingWiki API

Installation

pip install pcgw_api

Usage

Searching

import pcgw_api
client = pcgw_api.PCGW()
for result in client.search("Celeste"):
  print(result)

Search is performed with a SQL LIKE query. In the future you will be able to search with opensearch, allowing more flexible results at the expense of less informative data wich will require further requests to get interesting information.

There is also PCGW.async_search should you need an asynchronous version.

Fetching data

The above search function returns Game objects, which have all the information from the tables of the PCGamingWiki database. The tables are accessible as attributes:

cuphead = client.search("Cuphead")[0]
print(cuphead.infobox.genres)
print(cuphead.availability.available_from)
print(cuphead.multiplayer.local_players)

See tables.py for the full list of available fields.

Dates are parsed as datetime python objects and fields indicating the support of the game for a feature are generally parsed into a Support enum object:

print(', '.join(str(date.year) for date in cuphead.infobox.released))
print(cuphead.input.controller_hotplugging == pcgw_api.Support.TRUE) # True
print(cuphead.input.controller_hotplugging == pcgw_api.Support.HACKABLE) # False
print(cuphead.input.mouse_sensitivity == pcgw_api.Support.NA) # True

Support is falsy for the values NULL, NA, UNKNOWN and FALSE, truthy otherwise:

print(bool(cuphead.input.controller_support)) # True
if cuphead.input.controller_support:
  print("This will be printed")

Language and engine information require additionnal requests to fetch the data:

# the data is fetched on the first call to Game.get_languages/engines
print('\n'.join(f'{l.language} audio:{l.audio} subtitles:{l.subtitles}' for l in cuphead.get_languages()))
print(', '.join(e.engine for e in cuphead.get_engines()))

It is possible to request specific games with PCGW.get_game or PCGW.get_games:

print(client.get_game(page_id=63516).name) # Cuphead
print(client.get_game(steam_id=268910).name) # Cuphead
print(client.get_game(gog_id=1963513391).name) # Cuphead
print(client.get_game(page_name="Cuphead").name)
results = client.get_games(page_names=("Fez", "Limbo", "notagame"))
print(results["Fez"].name) # Fez
print(results["notagame"]) # None

get_games accepts the parameters page_ids and page_names and returns a dictionary with these identifiers as keys to the resulting Game objects. Fetching multiple games at a time with steam or gog ids is not supported as these ids can actually refer to more than one PCGamingWiki page.

It is possible to retrieve the set of values of a given field in the database:

print(client.get_possible_values('themes'))
print(client.get_possible_values('available_on'))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pcgw_api-0.1.1.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pcgw_api-0.1.1-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file pcgw_api-0.1.1.tar.gz.

File metadata

  • Download URL: pcgw_api-0.1.1.tar.gz
  • Upload date:
  • Size: 23.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.24.1 CPython/3.13.3 Linux/6.14.3-arch1-1

File hashes

Hashes for pcgw_api-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2ebc5766542ca965ecf66b76ea2059cc7b2e8428d92660b22d59fb1945181d1f
MD5 d883657b65f503641d0e46925b5cfb83
BLAKE2b-256 1a30bd9726c6f5a41f6d846959b1cfa13abff93c96851d575e2628c487dab099

See more details on using hashes here.

File details

Details for the file pcgw_api-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pcgw_api-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.24.1 CPython/3.13.3 Linux/6.14.3-arch1-1

File hashes

Hashes for pcgw_api-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 23d6cac65edba05570aa146a8269d0ee6959983fbe50a212cf174507e75977bb
MD5 8c2be571ac90120e13790b80eb53a0e8
BLAKE2b-256 90cd653972ae4b62ebce81b1dab8f828e34e6cb8bb09ce7a8e2ed15341ca8a0f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page