From 9ab44020e549e1a669e30c635adc160cff1d20f1 Mon Sep 17 00:00:00 2001 From: Thomas Arnold Date: Mon, 27 Nov 2023 23:48:50 -0500 Subject: [PATCH 1/2] Added another example to the readme --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index eea5ddc..fd4b1e8 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,17 @@ games_message.ParseFromString(byte_array) # Fills the protobuf message object wi games = games_message.games ``` +Note that depending on what type of query you're doing, you will need to parse it differently. Consider the following example of getting covers with a Protobuf API request: +``` +from igdb.igdbapi_pb2 import CoverResult +byte_array = wrapper.api_request( + 'covers.pb', + 'fields url; limit 10;' + ) +covers_message = CoverResult() +covers_message.ParseFromString(byte_array) +covers = [cover.url for cover in covers_message.covers] + ## Exceptions The wrapper throws a [`requests.HTTPError`](https://2.python-requests.org/en/master/api/#requests.HTTPError) when an exception occurs from the API. From 766abf05fe44659ed1ada24510518133cfb99a2e Mon Sep 17 00:00:00 2001 From: Thomas Arnold Date: Mon, 27 Nov 2023 23:52:25 -0500 Subject: [PATCH 2/2] more clarification --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fd4b1e8..c8436e6 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,8 @@ byte_array = wrapper.api_request( covers_message = CoverResult() covers_message.ParseFromString(byte_array) covers = [cover.url for cover in covers_message.covers] +``` +You may need to do some digging around in igdbapi_pb2.py (being careful not to actually edit anything) to look for similar functions to GameResult() and CoverResult() based on what you are trying to query for. ## Exceptions