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 --upgrade
Manual
git clone git@github.com:onejeuu/stalcraft-api.git
cd stalcraft-api
pip install -r requirements.txt


⚡ Quick Start

from stalcraft import AppClient

TOKEN = "YOUR_TOKEN"

client = AppClient(token=TOKEN)


🚫 Exceptions

Exception
├── InvalidToken
├── StalcraftApiException
│   ├── Unauthorised
│   ├── InvalidParameter
│   ├── NotFound
│   └── RateLimitException
└── ItemException
    ├── ListingJsonNotFound
    └── ItemIdNotFound


🔑 Tokens

from stalcraft import Authorization

CLIENT_ID = "YOUR_CLIENT_ID"
CLIENT_SECRET = "YOUR_CLIENT_SECRET"

auth = Authorization(client_id=CLIENT_ID, client_secret=CLIENT_SECRET)
Get App Token
print()
print("Get App Token")
print(auth.get_app_token())

Get User Token
print()
print("Get User Code")
print(auth.user_code_url)

auth.input_code()

# or
# auth.code = "USER_CODE"

print()
print("Get User Token")
print(auth.get_user_token())

Refresh User Token
REFRESH_TOKEN = "USER_REFRESH_TOKEN"

print()
print("Refresh User Token")
print(auth.update_token(REFRESH_TOKEN))


📋 Output Formats

from stalcraft import AppClient

TOKEN = "YOUR_TOKEN"

client = AppClient(token=TOKEN)

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

client.json = True

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

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

Output:

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-30T05:16:52Z',
    'previousEnd': '2023-01-30T05:21:52Z'
}

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.3.0.tar.gz (55.8 kB view hashes)

Uploaded Source

Built Distribution

stalcraft_api-0.3.0-py3-none-any.whl (58.6 kB view hashes)

Uploaded Python 3

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