### Set up Python Development Environment Source: https://github.com/twitchtv/igdb-api-python/blob/master/README.md Instructions for setting up the Python development environment using `pipenv`. This installs `pipenv` globally and then installs project dependencies, including development dependencies. ```bash pip install --user pipenv pipenv install --dev ``` -------------------------------- ### Install IGDB Python API Wrapper Source: https://github.com/twitchtv/igdb-api-python/blob/master/README.md This command installs the `igdb-api-v4` Python package using pip, making the wrapper available for use in your projects. ```py pip install igdb-api-v4 ``` -------------------------------- ### Install and Generate Protobufs on Windows Source: https://github.com/twitchtv/igdb-api-python/blob/master/README.md Commands to download the `protoc` compiler for Windows and then use it to generate Python Protocol Buffer classes from the `igdbapi.proto` definition file. ```batch set PB_REL="https://github.com/protocolbuffers/protobuf/releases" set PB_VERSION=3.13.0 set PB_OS=win set PB_ARCH=64 curl -LO %PB_REL%/download/v%PB_VERSION%/protoc-%PB_VERSION%-%PB_OS%%PB_ARCH%.zip ``` ```batch cd protoc-3.13.0-win64\bin protoc.exe -I=../../src/igdb --python_out=../../src/igdb igdbapi.proto ``` -------------------------------- ### Make API Requests with IGDBWrapper (JSON & Protobuf) Source: https://github.com/twitchtv/igdb-api-python/blob/master/README.md Demonstrates how to use the `api_request` method to query the IGDB API. It shows examples for both raw JSON responses (by omitting `.pb` suffix) and Protocol Buffer responses (by adding `.pb` suffix to the endpoint), including how to parse the Protobuf byte array into a `GameResult` object. ```py '''With a wrapper instance already created''' # JSON API request byte_array = wrapper.api_request( 'games', 'fields id, name; offset 0; where platforms=48;' ) # parse into JSON however you like... # Protobuf API request from igdb.igdbapi_pb2 import GameResult byte_array = wrapper.api_request( 'games.pb', # Note the '.pb' suffix at the endpoint 'fields id, name; offset 0; where platforms=48;' ) games_message = GameResult() games_message.ParseFromString(byte_array) # Fills the protobuf message object with the response games = games_message.games ``` -------------------------------- ### Generate Protobufs on Mac Source: https://github.com/twitchtv/igdb-api-python/blob/master/README.md Command to run the `protoc` compiler on macOS to generate Python Protocol Buffer classes from the `igdbapi.proto` definition file. ```bash protoc -I=. --python_out=. igdbapi.proto ``` -------------------------------- ### Initialize IGDBWrapper with Twitch Credentials Source: https://github.com/twitchtv/igdb-api-python/blob/master/README.md Create an instance of `IGDBWrapper` by providing your Twitch Client-ID and App Access Token. This object is essential for making API requests to IGDB. ```py from igdb.wrapper import IGDBWrapper wrapper = IGDBWrapper("YOUR_CLIENT_ID", "YOUR_APP_ACCESS_TOKEN") ``` -------------------------------- ### requests.HTTPError Exception Source: https://github.com/twitchtv/igdb-api-python/blob/master/README.md The exception thrown by the `igdb-api-v4` wrapper when an error occurs during an API request, originating from the underlying `requests` library. ```APIDOC requests.HTTPError Description: Raised for HTTP errors (e.g., 4xx or 5xx responses) during API calls. Source: requests library ``` -------------------------------- ### IGDBWrapper.api_request Method Source: https://github.com/twitchtv/igdb-api-python/blob/master/README.md The primary method for querying the IGDB API. It sends an `APICalypse`-like query to a specified endpoint and returns a byte array. The response can be either raw JSON or Protocol Buffer data, depending on the endpoint suffix. ```APIDOC IGDBWrapper.api_request(endpoint: str, query: str) -> bytes endpoint: The API endpoint to query (e.g., 'games', 'games.pb'). query: An APICalypse-like query string (e.g., 'fields id, name;'). Returns: A byte array containing the API response. Throws: requests.HTTPError on API exceptions. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.