Skip to content

Commit

Permalink
Improved README
Browse files Browse the repository at this point in the history
  • Loading branch information
LuCkEr- committed Aug 23, 2021
1 parent f228c65 commit 9f74e03
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# PyScoreSaber
Score Saber API client

Comes with caching and rate limiting out of the box.

There is also a test mode which can be enabled like this ```scoresaber = ScoreSaber(test_mode=True)```.
This will return random data instead of making API requests to Score Saber.

### Usage:
```python
import asyncio
Expand All @@ -13,6 +18,24 @@ async def main():
player = await scoresaber.get_player_full("76561198029447509")
print(player)

# Get fake data instead
async def main_fake():
async with ScoreSaber(test_mode=True) as scoresaber:
player = await scoresaber.get_player_basic("76561198029447509")
print(player)

asyncio.run(main())
asyncio.run(main_fake())
```

### Faker provider:
```python
from faker import Faker
from pyscoresaber import ScoreSaberProvider

faker = Faker()
faker.add_provider(ScoreSaberProvider)

player = faker.player_basic("76561198029447509")
print(player)
```
7 changes: 7 additions & 0 deletions src/pyscoresaber/scoresaber.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,10 @@ async def get_top_scores(self, player_id: str, page: int = 1) -> List[Score]:
top_score_list.append(Score.from_dict(top_score))

return top_score_list

async def __aenter__(self):
await self.start()
return self

async def __aexit__(self, exc_type, exc_val, exc_tb):
await self.close()

0 comments on commit 9f74e03

Please sign in to comment.