<h1 align="center">stalcraft-api unofficial python library</h1>
<div align="center">
<a href="https://pypi.org/project/stalcraft-api" alt="PyPi Package Version">
<img src="https://img.shields.io/pypi/v/stalcraft-api.svg?style=flat-square"/></a>
<a href="https://pypi.org/project/stalcraft-api" alt="Supported python versions">
<img src="https://img.shields.io/pypi/pyversions/stalcraft-api.svg?style=flat-square"/></a>
<a href="https://opensource.org/licenses/MIT" alt="MIT License">
<img src="https://img.shields.io/pypi/l/stalcraft-api.svg?style=flat-square"/></a>
</div>
<br>
<div align="center">
<p>
<b>Official API documentation:</b> https://eapi.stalcraft.net
</p>
<p>
<b>Before you can use the API, you must register your application and receive approval<b>
</p>
<p>
<b>For testing Demo API is available<b>
</p>
<p>
<a href="https://eapi.stalcraft.net/registration.html">more about applications</a>
</p>
</div>
<br>
# 🔧 Install
### Pip
```console
pip install stalcraft-api -U
```
<details>
<summary>Manual</summary>
```console
git clone git@github.com:onejeuu/stalcraft-api.git
```
```console
cd stalcraft-api
```
```console
poetry install
```
</details>
<br>
# ⚡ Quick Start
```python
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))
```
<details>
<summary>🐇 Asyncio</summary>
```python
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())
```
</details>
<br>
# 🚫 Exceptions
```
StalcraftApiException
├── InvalidToken
├── MissingCredentials
├── ApiRequestError
│ ├── RequestUnauthorised
│ ├── RequestInvalidParameter
│ ├── RequestNotFound
│ └── RateLimitReached
└── ItemIdError
├── ListingJsonNotFound
└── ItemIdNotFound
```
<br>
# 🔑 Authorization
```python
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)
```
<details>
<summary>Get App Token</summary>
```python
print(app_auth.get_token())
```
</details>
<br>
<details>
<summary>Get User Token</summary>
```python
print("Go to:", user_auth.code_url)
code = input("Enter code:")
print()
print(user_auth.get_token(code))
```
</details>
<br>
<details>
<summary>Refresh User Token</summary>
```python
REFRESH_TOKEN = "REFRESH_TOKEN"
print(user_auth.refresh_token(REFRESH_TOKEN))
```
</details>
<br>
# 📋 Output Formats
```python
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:
```python
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'
}
```
Raw data
{
"_id": null,
"home_page": "https://github.com/onejeuu/stalcraft-api",
"name": "stalcraft-api",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.11,<4.0",
"maintainer_email": "",
"keywords": "stalcraft,api,stalcraft-api,api-client",
"author": "onejeuu",
"author_email": "bloodtrail@beber1k.ru",
"download_url": "https://files.pythonhosted.org/packages/27/08/29c445c2819a8b4a2b3ed9774579c68086b7a5095ad30d9640b5203d1703/stalcraft_api-1.1.1.tar.gz",
"platform": null,
"description": "<h1 align=\"center\">stalcraft-api unofficial python library</h1>\n\n<div align=\"center\">\n <a href=\"https://pypi.org/project/stalcraft-api\" alt=\"PyPi Package Version\">\n <img src=\"https://img.shields.io/pypi/v/stalcraft-api.svg?style=flat-square\"/></a>\n <a href=\"https://pypi.org/project/stalcraft-api\" alt=\"Supported python versions\">\n <img src=\"https://img.shields.io/pypi/pyversions/stalcraft-api.svg?style=flat-square\"/></a>\n <a href=\"https://opensource.org/licenses/MIT\" alt=\"MIT License\">\n <img src=\"https://img.shields.io/pypi/l/stalcraft-api.svg?style=flat-square\"/></a>\n</div>\n\n\n<br>\n\n<div align=\"center\">\n <p>\n <b>Official API documentation:</b> https://eapi.stalcraft.net\n </p>\n <p>\n <b>Before you can use the API, you must register your application and receive approval<b>\n </p>\n <p>\n <b>For testing Demo API is available<b>\n </p>\n <p>\n <a href=\"https://eapi.stalcraft.net/registration.html\">more about applications</a>\n </p>\n</div>\n\n\n<br>\n\n# \ud83d\udd27 Install\n\n### Pip\n\n```console\npip install stalcraft-api -U\n```\n\n<details>\n<summary>Manual</summary>\n\n```console\ngit clone git@github.com:onejeuu/stalcraft-api.git\n```\n\n```console\ncd stalcraft-api\n```\n\n```console\npoetry install\n```\n</details>\n\n\n<br>\n\n# \u26a1 Quick Start\n\n```python\nfrom stalcraft import AppClient, Region\n\n# Only as example.\n# Do not store your credentials in code.\nTOKEN = \"YOUR_TOKEN\"\n\nclient = AppClient(token=TOKEN)\n\nprint(client.emission(Region.EU))\n```\n\n<details>\n<summary>\ud83d\udc07 Asyncio</summary>\n\n```python\nimport asyncio\nfrom stalcraft import Region\nfrom stalcraft.asyncio import AsyncAppClient\n\nTOKEN = \"YOUR_TOKEN\"\n\nasync def main():\n client = AsyncAppClient(token=TOKEN)\n\n print(await client.emission(Region.EU))\n\nasyncio.run(main())\n```\n\n</details>\n\n<br>\n\n\n# \ud83d\udeab Exceptions\n\n```\nStalcraftApiException\n\u251c\u2500\u2500 InvalidToken\n\u251c\u2500\u2500 MissingCredentials\n\u251c\u2500\u2500 ApiRequestError\n\u2502 \u251c\u2500\u2500 RequestUnauthorised\n\u2502 \u251c\u2500\u2500 RequestInvalidParameter\n\u2502 \u251c\u2500\u2500 RequestNotFound\n\u2502 \u2514\u2500\u2500 RateLimitReached\n\u2514\u2500\u2500 ItemIdError\n \u251c\u2500\u2500 ListingJsonNotFound\n \u2514\u2500\u2500 ItemIdNotFound\n```\n\n<br>\n\n# \ud83d\udd11 Authorization\n\n```python\nfrom stalcraft import AppAuth, UserAuth\n\n# Only as example.\n# Do not store your credentials in code.\nCLIENT_ID = \"YOUR_CLIENT_ID\"\nCLIENT_SECRET = \"YOUR_CLIENT_SECRET\"\n\napp_auth = AppAuth(CLIENT_ID, CLIENT_SECRET)\nuser_auth = UserAuth(CLIENT_ID, CLIENT_SECRET)\n```\n\n<details>\n<summary>Get App Token</summary>\n\n```python\nprint(app_auth.get_token())\n```\n\n</details>\n\n<br>\n\n<details>\n<summary>Get User Token</summary>\n\n```python\nprint(\"Go to:\", user_auth.code_url)\n\ncode = input(\"Enter code:\")\n\nprint()\nprint(user_auth.get_token(code))\n```\n\n</details>\n\n<br>\n\n<details>\n<summary>Refresh User Token</summary>\n\n```python\nREFRESH_TOKEN = \"REFRESH_TOKEN\"\n\nprint(user_auth.refresh_token(REFRESH_TOKEN))\n```\n\n</details>\n\n\n<br>\n\n# \ud83d\udccb Output Formats\n\n```python\nfrom stalcraft import AppClient\n\nTOKEN = \"YOUR_TOKEN\"\n\nclient = AppClient(token=TOKEN)\n\nprint(\"Pydantic Object:\")\nprint(client.emission())\n\nclient = AppClient(TOKEN, json=True)\n\n# or\n# client.json = True\n\nprint()\nprint(\"Json:\")\nprint(client.emission())\n```\n\n### Output:\n\n```python\nPydantic Object:\nEmission(\n current_start=None,\n previous_start=datetime.datetime(2023, 1, 30, 12, 0, 0, tzinfo=datetime.timezone.utc),\n previous_end=datetime.datetime(2023, 1, 30, 12, 5, 0, tzinfo=datetime.timezone.utc)\n)\n\nJson:\n{\n 'previousStart': '2023-01-30T12:00:00Z',\n 'previousEnd': '2023-01-30T12:05:00Z'\n}\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "stalcraft api unofficial python library",
"version": "1.1.1",
"project_urls": {
"Homepage": "https://github.com/onejeuu/stalcraft-api",
"Repository": "https://github.com/onejeuu/stalcraft-api"
},
"split_keywords": [
"stalcraft",
"api",
"stalcraft-api",
"api-client"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "22d28cfc87c82bab32a281806b4c13f82e343ca80fcad302e8617eb61d52e1b6",
"md5": "1b6289322c439eebaa9f0beb3ee477ad",
"sha256": "2a759ae1b6497fe13bf633d5066d6cda0d5dbef9d6628ace9b6e5730938ce3c0"
},
"downloads": -1,
"filename": "stalcraft_api-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1b6289322c439eebaa9f0beb3ee477ad",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11,<4.0",
"size": 75529,
"upload_time": "2023-10-24T13:32:01",
"upload_time_iso_8601": "2023-10-24T13:32:01.504226Z",
"url": "https://files.pythonhosted.org/packages/22/d2/8cfc87c82bab32a281806b4c13f82e343ca80fcad302e8617eb61d52e1b6/stalcraft_api-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "270829c445c2819a8b4a2b3ed9774579c68086b7a5095ad30d9640b5203d1703",
"md5": "ec645c2b24a56934af125342369ea60e",
"sha256": "bedb1c73b48882111b5b2e6cda9400599e9ca6a2c167e26071faf9341de3a7f2"
},
"downloads": -1,
"filename": "stalcraft_api-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "ec645c2b24a56934af125342369ea60e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11,<4.0",
"size": 62213,
"upload_time": "2023-10-24T13:32:03",
"upload_time_iso_8601": "2023-10-24T13:32:03.203547Z",
"url": "https://files.pythonhosted.org/packages/27/08/29c445c2819a8b4a2b3ed9774579c68086b7a5095ad30d9640b5203d1703/stalcraft_api-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-24 13:32:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "onejeuu",
"github_project": "stalcraft-api",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "stalcraft-api"
}