Skip to main content

stalcraft-api unofficial python library

Project description

stalcraft-api unofficial python library

PyPi Package Version

Supported python versions

MIT License

📄 Official API documentation: https://eapi.stalcraft.net

ℹ️ Before you can use the API, you must register your application and receive approval

ℹ️ For testing Demo API is available

more about applications


Setup

pip install stalcraft-api --upgrade

Quick Start

from stalcraft import AppClient, BaseUrl



TOKEN = "YOUR_TOKEN"



client = AppClient(TOKEN, BaseUrl.PRODUCTION)

Usage Examples

AppClient
from stalcraft import AppClient, Region, Sort, Order



TOKEN = "YOUR_TOKEN"



client = AppClient(TOKEN)



print()

print("List of regions")

print(client.regions())



print()

print("List of clans with limit 2")

print(client.clans(limit=2))



print()

print("Information about emission on NA server")

print(client.emission(Region.NA))



print()

print("List of lots for item with id 'y1q9'")

print("With offset 5, limit 2, sort by buyout price and order by descending")

print(client.auction("y1q9").lots(offset=5, limit=2, sort=Sort.BUYOUT_PRICE, order=Order.DESC))



print()

print("List of price history for item with id 'y1q9'")

print(client.auction("y1q9").price_history())



print()

print("Information about clan with id '647d6c53-b3d7-4d30-8d08-de874eb1d845'")

print(client.clan("647d6c53-b3d7-4d30-8d08-de874eb1d845").info())

UserClient
from stalcraft import UserClient, Region



TOKEN = "YOUR_TOKEN"



client = UserClient(TOKEN)



# + all methods from AppClient



print("List of characters created on EU server by the user by which used access token was provided")

print(client.characters(Region.EU))



print()

print("List of friends character names who are friend with 'Test-1'")

print(client.friends("Test-1"))



print()

print("Members in clan with id '647d6c53-b3d7-4d30-8d08-de874eb1d845'")

print("Can be used only when using user access token and that user has at least one character in that clan.")

print(client.clan("647d6c53-b3d7-4d30-8d08-de874eb1d845").members())

Find Item ID by name
from stalcraft import AppClient, LocalItem, WebItem



TOKEN = "YOUR_TOKEN"



client = AppClient(TOKEN)



print()

print("Search by local file")

print(client.auction(LocalItem("Snowflake")).lots())



print()

print("(Not reliable)")

print("Search by listing.json in stalcraft-database github repository")

print(client.auction(WebItem("Snowflake", folder="ru")).lots())

Exceptions
from stalcraft import (

    UserClient, LocalItem,

    InvalidToken, StalcraftApiException, ItemException

)



TOKEN = "YOUR_TOKEN"



client = UserClient(TOKEN)



print()

print("If token is invalid")

try:

    client = UserClient("test1234567890")

except InvalidToken as e:

    print("Error:", e)



print()

print("If an item with that name does not exist")

try:

    print(LocalItem("test"))

except ItemException as e:

    print("Error:", e)



print()

print("If one of parameters is invalid")

try:

    print(client.auction("test").price_history())

except StalcraftApiException as e:

    print("Error:", e)

Output Formats

from stalcraft import AppClient



# Optional

from rich import print



TOKEN = "YOUR_TOKEN"



client = AppClient(TOKEN)



print()

print("Object:")

print(client.emission())



# or client = AppClient(TOKEN, json=True)

client.json = True



print()

print("Json:")

print(client.emission())

Output:

Object:

Emission(

    current_start=datetime.datetime(2023, 1, 27, 9, 28, 16, 656875, tzinfo=datetime.timezone.utc),

    previous_start=datetime.datetime(2023, 1, 27, 7, 26, 16, 656875, tzinfo=datetime.timezone.utc),

    previous_end=datetime.datetime(2023, 1, 27, 7, 31, 16, 656875, tzinfo=datetime.timezone.utc)

)



Json:

{

    'currentStart': '2023-01-27T09:28:16.829929Z',

    'previousStart': '2023-01-27T07:26:16.829929Z',

    'previousEnd': '2023-01-27T07:31:16.829929Z'

}

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

stalcraft-api-0.1.3.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

stalcraft_api-0.1.3-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file stalcraft-api-0.1.3.tar.gz.

File metadata

  • Download URL: stalcraft-api-0.1.3.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for stalcraft-api-0.1.3.tar.gz
Algorithm Hash digest
SHA256 a9db12168d663c1436069fc3541a89f404cb89e696540a4d42858e620bfdb800
MD5 af4a99ea7a3a29f2813a2d3681c4386c
BLAKE2b-256 1230b9b9f2afb314217d831292930fd4f1df508b7dbe7953b47f53cf28e95f74

See more details on using hashes here.

File details

Details for the file stalcraft_api-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: stalcraft_api-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for stalcraft_api-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e487360096784e1bb2ca13ae1c83a238bec9acfec1c87600adcd52e3544aebe1
MD5 cb2e44a631249ed1765bea4a47723727
BLAKE2b-256 7fe396ef3da07ea6f7154a7d663e43b1afdb2ca65dfcaf23b2d6c58393bdd7c3

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