-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added another code example to the readme #35
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -68,6 +68,19 @@ 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: | ||||||
``` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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] | ||||||
``` | ||||||
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. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure the final sentence is necessary or valuable. It is quite common to have to look through source code of various packages, especially ones that aren't so popular such as this one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't know that this was necessary, especially considering my Python linter in VS Code did not pick up on GameResult() or CoverResult(). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I don't think any IDE would pick those up because of how they're added to the python globals. |
||||||
|
||||||
## Exceptions | ||||||
|
||||||
The wrapper throws a [`requests.HTTPError`](https://2.python-requests.org/en/master/api/#requests.HTTPError) when an exception occurs from the API. | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.