async API wrapper for Tarkov Changes written in Python.
Project description
A Wrapper for the Tarkov Changes API.
Quick Examples
Basic use with use client
import tvc
import asyncio
from tvc import Ammunition
from typing import List
TOKEN: str = 'blahblah some token string'
client = tvc.TVCClient(token=TOKEN)
async def main():
ammunition: List[Ammunition] = await client.fetch_ammunition('7.62x39mm BP gzh')
if not ammunition:
# fetch result can be return empty list.
# If the list of ammunition what responded to is empty.
print('Can not found ammunition!')
return
for ammo in ammunition:
print(f"Name: {ammo}")
# Returns all entries if you do not insert a query into the fetch function argument.
ammunition: List[Ammunition] = await client.fetch_ammunition()
for ammo in ammunition:
print(f"Name: {ammo}")
if __name__ == '__main__':
# Use the pre-cache `start` function to use something like client.armors, client.ammunition, etc.
# If you're not going to use this property, you don't have to call this.
client.start()
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
Simple to use without client declaration
import asyncio
from tvc import Ammunition, TVCClient
from typing import List
TOKEN: str = 'blahblah some token string'
async def main():
async with TVCClient(TOKEN) as api:
ammunition: List[Ammunition] = await api.fetch_ammunition('7.62x39mm BP gzh')
if not ammunition:
# fetch result can be return empty list.
# If the list of ammunition what responded to is empty.
print('Can not found ammunition!')
return
for ammo in ammunition:
print(f"Name: {ammo}")
# Returns all entries if you do not insert a query into the fetch function argument.
ammunition: List[Ammunition] = await api.fetch_ammunition()
for ammo in ammunition:
print(f"Name: {ammo}")
# When you exit the `async with` syntax, aiohttp.ClientSession is automatically and securely terminated.
# When you use the `async with` with again, a new aiohttp.ClientSession is created again.
async with TVCClient(TOKEN) as api:
...
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for tarkov_changes.py-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 622e919ab21e4fd4cf3d85ed02cc85c9692426406a9d539a5b5f5dd3651dd849 |
|
MD5 | 8bde3dfb7a616797874187f33dd28871 |
|
BLAKE2b-256 | a67fd91dd028a210400478734778edabccfc4c6cad8bdfb9a15d37f3c44ec46a |