Skip to main content

stalcraft api unofficial python library

Project description

stalcraft-api unofficial python library


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


🔧 Install

Pip

pip install stalcraft-api -U
Manual
git clone git@github.com:onejeuu/stalcraft-api.git
cd stalcraft-api
poetry install

⚡ Quick Start

from stalcraft import AppClient, Region

# Only as example.
# Do not store your credentials in code.
TOKEN = "YOUR_TOKEN"

client = AppClient(token=TOKEN)

print(client.emission(Region.EU))
🐇 Asyncio
import asyncio
from stalcraft import Region
from stalcraft.asyncio import AsyncAppClient

TOKEN = "YOUR_TOKEN"

async def main():
    client = AsyncAppClient(token=TOKEN)

    print(await client.emission(Region.EU))

asyncio.run(main())

🚫 Exceptions

StalcraftApiException
├── InvalidToken
├── MissingCredentials
├── ApiRequestError
│   ├── RequestUnauthorised
│   ├── RequestInvalidParameter
│   ├── RequestNotFound
│   └── RateLimitReached
└── ItemIdError
    ├── ListingJsonNotFound
    └── ItemIdNotFound

🔑 Authorization

from stalcraft import AppAuth, UserAuth

# Only as example.
# Do not store your credentials in code.
CLIENT_ID = "YOUR_CLIENT_ID"
CLIENT_SECRET = "YOUR_CLIENT_SECRET"

app_auth = AppAuth(CLIENT_ID, CLIENT_SECRET)
user_auth = UserAuth(CLIENT_ID, CLIENT_SECRET)
Get App Token
print(app_auth.get_token())

Get User Token
print("Go to:", user_auth.code_url)

code = input("Enter code:")

print()
print(user_auth.get_token(code))

Refresh User Token
REFRESH_TOKEN = "REFRESH_TOKEN"

print(user_auth.refresh_token(REFRESH_TOKEN))

📋 Output Formats

from stalcraft import AppClient

TOKEN = "YOUR_TOKEN"

client = AppClient(token=TOKEN)

print("Pydantic Object:")
print(client.emission())

client = AppClient(TOKEN, json=True)

# or
# client.json = True

print()
print("Json:")
print(client.emission())

Output:

Pydantic Object:
Emission(
    current_start=None,
    previous_start=datetime.datetime(2023, 1, 30, 12, 0, 0, tzinfo=datetime.timezone.utc),
    previous_end=datetime.datetime(2023, 1, 30, 12, 5, 0, tzinfo=datetime.timezone.utc)
)

Json:
{
    'previousStart': '2023-01-30T12:00:00Z',
    'previousEnd': '2023-01-30T12:05:00Z'
}

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-1.1.1.tar.gz (62.2 kB view details)

Uploaded Source

Built Distribution

stalcraft_api-1.1.1-py3-none-any.whl (75.5 kB view details)

Uploaded Python 3

File details

Details for the file stalcraft_api-1.1.1.tar.gz.

File metadata

  • Download URL: stalcraft_api-1.1.1.tar.gz
  • Upload date:
  • Size: 62.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.0 Windows/10

File hashes

Hashes for stalcraft_api-1.1.1.tar.gz
Algorithm Hash digest
SHA256 bedb1c73b48882111b5b2e6cda9400599e9ca6a2c167e26071faf9341de3a7f2
MD5 ec645c2b24a56934af125342369ea60e
BLAKE2b-256 270829c445c2819a8b4a2b3ed9774579c68086b7a5095ad30d9640b5203d1703

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stalcraft_api-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 75.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.0 Windows/10

File hashes

Hashes for stalcraft_api-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a759ae1b6497fe13bf633d5066d6cda0d5dbef9d6628ace9b6e5730938ce3c0
MD5 1b6289322c439eebaa9f0beb3ee477ad
BLAKE2b-256 22d28cfc87c82bab32a281806b4c13f82e343ca80fcad302e8617eb61d52e1b6

See more details on using hashes here.

Supported by

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