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

Data already present

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.

Specific types

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")

Data needing more requests

Language and engine information require additionnal requests to fetch the data, it is fetched on the first call to Game.get_languages or Game.get_engines and then cached:

for l in cuphead.get_languages():
  print(f'{l.language} audio:{l.audio} subtitles:{l.subtitles}')
print(', '.join(e.engine for e in cuphead.get_engines()))

Fetching game information by ID

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 uses a single HTTP request. 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.

Helper functions

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

print(client.get_possible_values('Infobox_game', 'themes'))
print(client.get_possible_values('Infobox_game', 'available_on'))
print(client.get_possible_values('Input', 'other_button_prompts'))
print(client.get_possible_values('L10n', 'language'))

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.2.0.tar.gz (23.6 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.2.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pcgw_api-0.2.0.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.25.4 CPython/3.13.5 Linux/6.15.5-arch1-1

File hashes

Hashes for pcgw_api-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0d583b0b45f3982c0de5b1797f24dd32c618246ecd27874bbf4e7a34c54e2502
MD5 f4491dc75bcac6959fb307006f18dfbe
BLAKE2b-256 074793aaf6929ea93df8c462be8844649799322a1402b87edcbd3ab40c8f5ba1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pcgw_api-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.25.4 CPython/3.13.5 Linux/6.15.5-arch1-1

File hashes

Hashes for pcgw_api-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff37e111f09549163183f1104232d6319da1e373f571418765d060ffa991974a
MD5 0ce4606bf28a896d05e451e04006fba4
BLAKE2b-256 7468a48d115bf0dae251ea58bc34dca44f8fe9f275081f65653e02d44d89837d

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