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.2.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.2-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pcgw_api-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 d7eafcb642ffb1e93d054cde3c132e6c6b9c1ee538c045dec4d96e7b3b18c78e
MD5 4bc7047140f8c72086012b7b79244aff
BLAKE2b-256 1db06a027620d6fbf5f67ef3b68db7d267f8884bf49668b0710a21c13569d3ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pcgw_api-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 38670126035d22f64e5c097db918ab97655dabbd17a365197d15eaf650ae250e
MD5 9ab3b8fb4793e66f31e03811cc8dc881
BLAKE2b-256 74200e163680a28f648db903d5c71275a315735b66d1ed9e72d17b1ec059f903

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