Metadata-Version: 2.1
Name: rawg
Version: 0.3
Summary: RAWG.io API Wrapper
Home-page: https://github.com/uburuntu/rawg
Author: uburuntu
Author-email: bekbulatov.ramzan@ya.ru
License: UNKNOWN
Download-URL: https://github.com/uburuntu/rawg/archive/master.zip
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Programming Language :: Python :: 3
Description-Content-Type: text/markdown
Requires-Dist: aiohttp
Requires-Dist: pydantic
Requires-Dist: requests

# RAWG.io API Wrapper

[![Python](https://img.shields.io/badge/Python-3.6%20%7C%203.7%20%7C%203.8-blue.svg?longCache=true)]()
[![PyPI](https://img.shields.io/pypi/v/rawg.svg)](https://pypi.python.org/pypi/rawg)

[![Build Status](https://travis-ci.org/uburuntu/rawg.svg?branch=master)](https://travis-ci.org/uburuntu/rawg)
[![codecov](https://codecov.io/gh/uburuntu/rawg/branch/master/graph/badge.svg)](https://codecov.io/gh/uburuntu/rawg)
<!-- [![Codacy Badge](https://api.codacy.com/project/badge/Grade/aaf685a78dbf4377b8f36b401a5ccda1)](https://www.codacy.com/app/uburuntu/rawg?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=uburuntu/rawg&amp;utm_campaign=Badge_Grade) -->

Pretty simple API wrapper for RAWG.io with typings.

You can use both sync and async realizations. 

_Contributions are welcome!_

## API Usage

### Installation
Just
```
pip install rawg
``` 
or maybe `pip3`.

### Simple example
```python
from rawg import Rawg

r = Rawg()
s = r.search('half life 3')

result = s.results[0]
print(result.name, result.released)
```

### Async example

```python
import asyncio

from rawg import AioRawg
from rawg.types import RawgGame


async def main():
    rawg = AioRawg()

    search = await rawg.search('metal gear', page_size=3)
    requests = [rawg.info(game) for game in search.results]

    print('Search results:', search.count)
    for request in asyncio.as_completed(requests):
        game: RawgGame = await request
        print(game.name)
        print('--', 'Released:', game.released)
        print('--', 'Rating:', game.rating)
        print('--', 'Genres:', ', '.join(genre.name for genre in game.genres))
        print('--', 'Available on:', ', '.join(p.platform.name for p in game.platforms))


if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
```

Result:
```
Search results: 1846
Metal Gear Solid
-- Released: 1998-09-03
-- Rating: 4.23
-- Genres: Action, Shooter, Adventure
-- Available on: PlayStation, PS Vita, PC, PSP, PlayStation 3
Metal Gear
-- Released: 1987-07-07
-- Rating: 3.95
-- Genres: 
-- Available on: PC, Wii, NES, Commodore / Amiga
METAL GEAR RISING: REVENGEANCE
-- Released: 2013-02-19
-- Rating: 4.14
-- Genres: Action
-- Available on: Xbox 360, PlayStation 3, PC
```

### Manual

#### Methods
API have 3 methods:
* `search` вЂ” search for a game by name, return type: `RawgSearch`
  * `RawgSearch` have attribute `results` of type `List[RawgGameSearch]`
* `suggested` вЂ” find more similar games via RAWG ML, return type: `RawgSuggested`
  * `RawgSuggested` have attribute `results` of type `List[RawgGameSuggested]`
* `info` вЂ” detailed information about the game, return type: `RawgGame`
  * `RawgGame` is more detailed than `RawgGameSearch` and `RawgGameSuggested`

#### Types
This library uses [pydantic](https://github.com/samuelcolvin/pydantic/) for parsing API responses.
Main types are: `RawgPlatformData`, `RawgPlatform`, `RawgStoreData`, `RawgStore`, `RawgRating`, `RawgAddedByStatus`, `RawgChartYear`, `RawgCharts`, `RawgClips`, `RawgClip`, `RawgScreenshot`, `RawgGenre`, `RawgGameBase`, `RawgGame`, `RawgGameSearch`, `RawgGameSuggested`, `RawgSearch`. And declared in [rawg/types.py](rawg/types.py).


### In case of unsupported types
API results can change and the library may not parse the new result. So you can use parameter `raw_results` for requesting В«rawВ» dicts: 
```python
r = AioRawg(raw_results=True)
# Or
r = Rawg(raw_results=True)
```

## API Docs

**Link**: https://rawg.io/apidocs

#### API Rules
* every API request should have a `User-Agent` header with your app name
  * You can set your app name through argument `app_name`: `Rawg(app_name='Meduza')` or `AioRawg(app_name='Rawg.io Telegram Bot')` 
* no mass extraction & no cloning RAWG


## Another libraries

**Python**: laundmo/[rawgpy](https://pypi.org/project/rawgpy)

**Node.js**: orels1/[rawger](https://github.com/orels1/rawger)


