Skip to main content

async API wrapper for Tarkov Market written in Python.

Project description

PyPI GitHub release (latest by date including pre-releases) tarkov-market.com

async wrapper for Tarkov Market API written in Python.

Installing

Python 3.8 or higher is required

# Linux/macOS
python3 -m pip install -U tarkov-market.py

# Windows
py -3 -m pip install -U tarkov-market.py

Quick Examples

Basic use with use client

import asyncio
import tarkov_market

from typing import List
from tarkov_market import Item

TOKEN: str = 'YOUR API KEY'
market = tarkov_market.Client(token=TOKEN, refresh_rate=None)


async def main() -> None:
    # return only one of the search results
    item: Item = await market.fetch_item('TerraGroup Labs keycard (Red)')

    print(item.name, item.price)

    # return all search results
    items: List[Item] = await market.fetch_items('key')

    for item in items:
        print(item.name, item.price)

    '''
    The fetch functions has a limit of 300 requests per minute because it communicates directly with the API.
    If you have a large number of requests, check the example in the link below.

    cache example: https://github.com/Hostagen/tarkov-market.py/blob/master/examples/cache.py

    Unrestricted by pre-loading and caching data once.
    '''


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

Simple to use without client declaration

import asyncio

from typing import List
from tarkov_market import Client as TVMClient, Item

TOKEN: str = 'YOUR API KEY'


async def main():
    async with TVMClient(token=TOKEN) as api:
        item: Item = await api.fetch_item('TerraGroup Labs keycard (Red)')
        print(item.name, item.price)

        items: List[Item] = await api.fetch_items('key')

        for item in items:
            print(item.name, item.price)

    # 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 TVMClient(token=TOKEN) as api:
        ...


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

More Examples

https://github.com/Hostagen/tarkov-market.py/tree/master/examples

Update Logs

Check here for releases

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tarkov-market.py-0.15.2.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tarkov_market.py-0.15.2-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file tarkov-market.py-0.15.2.tar.gz.

File metadata

  • Download URL: tarkov-market.py-0.15.2.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for tarkov-market.py-0.15.2.tar.gz
Algorithm Hash digest
SHA256 84d6a54cafadec09b5731b94b3a775cb42327347defda9943d213852141a1368
MD5 74fe343b5979dded0ba52a0e36dcf6e8
BLAKE2b-256 50dac250932d761f550f19c4ac6030ef637c911d3f40e919d96311b4bee9bfe1

See more details on using hashes here.

File details

Details for the file tarkov_market.py-0.15.2-py3-none-any.whl.

File metadata

File hashes

Hashes for tarkov_market.py-0.15.2-py3-none-any.whl
Algorithm Hash digest
SHA256 72592a78ea7538f1c2b97554da08d96709ee07b7ad579375acf1c62e30b5a5d9
MD5 a6f6ab180c2f0b9afd6eb5398a4c2f0c
BLAKE2b-256 47705922e3cfef7c5854f1baaeb506e7ad3aeef446974870f61bf766b3d52d1a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page