Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
> **Note**
> 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.

```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
```py

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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The 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().

Copy link
Contributor

Choose a reason for hiding this comment

The 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.
Expand Down