Skip to main content

"Web API for VTES cards and TWDA.",

Project description

KRCG API

PyPI version Validation Python version License Code Style

A web API for V:tES based on the VEKN official card texts and the Tournament Winning Deck Archive (TWDA).

Portions of the materials are the copyrights and trademarks of Paradox Interactive AB, and are used with permission. All rights reserved. For more information please visit white-wolf.com.

Dark Pack

Online API and documentation

KRCG is a free to use (and documented) online API. Anyone is free to use it, without warranty.

Breaking changes will only be introduced at major version upgrades, after a proper deprecation period.

Contribute

Contributions are welcome !

This API is an offspring of the KRCG python package, so please refer to that repository for issues, discussions and contributions guidelines.

Examples

Query a card by name or ID, get text, rulings and image URL:

curl -X GET "http://127.0.0.1:8000/card/Alastor" -H  "accept: application/json"
{
    "id": 100038,
    "name": "Alastor",
    "_name": "Alastor",
    "types": ["Political Action"],
    "url": "https://static.krcg.org/card/alastor.jpg",
    "card_text": "Requires a justicar or Inner Circle member...",
    "rulings": {
        "links": {
            "[ANK 20200901]": "http://www.vekn.net/forum/rules-questions/78830-alastor-and-ankara-citadel#100653",
            "[LSJ 20040518]": "https://groups.google.com/d/msg/rec.games.trading-cards.jyhad/4emymfUPwAM/B2SCC7L6kuMJ"
        },
        "text": [
            "If the given weapon costs blood, the target Alastor pays the cost. [LSJ 20040518]",
            "Requirements do not apply. [ANK 20200901]"
        ]
    },
    "artists": ["Monte Moore"],
    "sets": {
        "Gehenna": [{ "rarity": "Rare", "release_date": "2004-05-17" }],
        "Keepers of Tradition": [{ "rarity": "Rare", "release_date": "2008-11-19" }],
        "Kindred Most Wanted": [
            {
                "copies": 1,
                "precon": "Alastors",
                "release_date": "2005-02-21"
            }
        ]
    },
    "scans": {
        "Gehenna": "https://static.krcg.org/card/set/gehenna/alastor.jpg",
        "Keepers of Tradition": "https://static.krcg.org/card/set/keepers-of-tradition/alastor.jpg",
        "Kindred Most Wanted": "https://static.krcg.org/card/set/kindred-most-wanted/alastor.jpg"
    }
}

Search for cards by text, type, discipline, title, city, artist, set, preconstructed starter, group, capacity, trait, sect, bonus values, etc.:

curl
    -X POST "http://127.0.0.1:8000/card_search"
    -H "Content-Type: application/json"
    -d "{\"type\":[\"political action\"],\"sect\":[\"anarch\"]}"
[
    "Anarch Salon",
    "Eat the Rich",
    "Firebrand",
    "Free States Rant",
    "Patsy",
    "Reckless Agitation",
    "Revolutionary Council",
    "Sweeper"
]

Get candidates for your decklist out of the TWDA:

curl
    -X POST "http://127.0.0.1:8000/candidates"
    -H  "Content-Type: application/json"
    -d "{\"cards\":[\"Cybele\",\"Nana Buruku\"]}"
[
  {
    "average": 14,
    "card": "Ashur Tablets",
    "deviation": 6.25,
    "score": 1
  },
  {
    "average": 1,
    "card": "Giant's Blood",
    "deviation": 0,
    "score": 1
  },
  {
    "average": 2,
    "card": "The Parthenon",
    "deviation": 0.81,
    "score": 1
  },
  {
    "average": 1,
    "card": "Archon Investigation",
    "deviation": 0,
    "score": 0.9
  },
  ...
]

And a few other features, including:

  • search decks in the TWDA, by cards, dates, author and number of players
  • deck list format conversion
  • retrieving a decklist from an Amaranth share URL
  • card name completions

Check the online documentation for more.

Hosting the web API

To host the web API, you can use pip to install it:

pip install "krcg-api"

No wsgi server is installed by default, you need to install one. HTTP web servers can then easily be configured to serve WSGI applications, check the documentation of your web server.

The API can be served with uWSGI:

uwsgi --module krcg_api.wsgi:application

or Gunicorn:

gunicorn krcg_api.wsgi:application

Two environment variables are expected: GITHUB_USERNAME and GITHUB_TOKEN, to allow the API to connect to Github as a user in order to post new rulings as issues on the repository (/submit-ruling endpoint).

See the Github help on how to generate a personal token for the account you want KRCG to use.

Development

The development version of KRCG installs uWSGI to serve the API, this is the preferred WSGI server for now.

$ pip install -e ".[dev]"
$ make serve
...
uwsgi socket 0 bound to TCP address 127.0.0.1:8000

You can check the API is running by using your browser on the provided address http://127.0.0.1:8000.

The environment variables GITHUB_USERNAME and GITHUB_TOKEN can be provided by a personal .env file at the root of the krcg folder (ignored by git):

export GITHUB_USERNAME="dedicated_github_username_for_the_api"
export GITHUB_TOKEN="the_matching_github_token"

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

krcg-api-2.5.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

krcg_api-2.5-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file krcg-api-2.5.tar.gz.

File metadata

  • Download URL: krcg-api-2.5.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.2

File hashes

Hashes for krcg-api-2.5.tar.gz
Algorithm Hash digest
SHA256 db82129c5755e70af088b9cc0b5ec070635a7ad3f2e79f32c4832d1e5516a19d
MD5 88d0bf2e26a5b77f61e91d3ae2d952e4
BLAKE2b-256 dc95e80ffef085d0f4bc778000b2cfcd69729e3f35a2a1042a09ca39cdfb4c20

See more details on using hashes here.

File details

Details for the file krcg_api-2.5-py3-none-any.whl.

File metadata

  • Download URL: krcg_api-2.5-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.2

File hashes

Hashes for krcg_api-2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 dddf6a0ea653eee36f1608fa606378efb570f68fa887a36e3078bef7da3a7eca
MD5 97b0f7616f421167b390838222506b64
BLAKE2b-256 a065fe8bc2b6ede096c5231661555238870963cd19e1095c15b2f5aaf653b0b2

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