Alessandro Lussana

PhD Student @ European Bioinformatics Institute

A survival machine with an interest in life and data sciences.

Personal webpage


When I casually stumbled upon dnd5eapi, sweet nostalgia hit me. I immediatly had to write my little script to fetch D&D 5.0 edition rules from the terminal via queries to this RESTful API. Which, to be fair, I believe is quite a cool idea: my (much) younger self would have loved to have something like that for the 3.5 edition during game sessions, to search and retrieve the stats and descriptions of items, classes, spells, etc - on the fly.

The idea behind this textual tool is the following: the user who wants to look up some information in the D&D knowledgebase will hold a simple conversation with a Candlekeep monk. This guy’s job is to send web requests to dnd5api and to parse the data obtained in json format, while actually pretending to be reading some tomes and not being in the slightiest way annoyed by the extremely limited dialogue options that I cared of giving him. In this way, the player just needs to ask the monk what they need to know, restricting the results by categories until reaching the desired entry.

Say you are casting Magic Missile, but you don’t remeber the amount of damage it can deal. Run ./ and …

 Candlekeep Monk:
 "Greetings. Just one moment and I'll help you with your quest."
 *Opens a tome and summons the Internet planar portal*

 Candlekeep Monk:
 "Here we are. What kind of knowledge are you looking for?"

{0: 'ability-scores',
 1: 'alignments',
 2: 'backgrounds',
 3: 'classes',
 4: 'conditions',
 5: 'damage-types',
 6: 'equipment',
 7: 'equipment-categories',
 8: 'feats',
 9: 'features',
 10: 'languages',
 11: 'levels',
 12: 'magic-items',
 13: 'magic-schools',
 14: 'monsters',
 15: 'proficiencies',
 16: 'races',
 17: 'rule-sections',
 18: 'rules',
 19: 'skills',
 20: 'spells',
 21: 'subclasses',
 22: 'subraces',
 23: 'traits',
 24: 'weapon-properties'}

 --> : 20

 Candlekeep Monk:
 "Let me see... I've got 319 results for spells.
 Do you know its name already? If not, try to use the first letters only."

 --> : Mag

{185: 'Mage Armor',
 186: 'Mage Hand',
 187: 'Magic Circle',
 188: 'Magic Jar',
 189: 'Magic Missile',
 190: 'Magic Mouth',
 191: 'Magic Weapon',
 192: 'Magnificent Mansion'}

 --> : 189

 Candlekeep Monk:
 "Here is what you asked for. Use it wisely."

    /\                                                                                      \

      {'_id': '62b248818b12b6a08c9fa6c1',
       'casting_time': '1 action',
       'classes': [{'index': 'sorcerer',
                    'name': 'Sorcerer',
                    'url': '/api/classes/sorcerer'},
                   {'index': 'wizard',
                    'name': 'Wizard',
                    'url': '/api/classes/wizard'}],
       'components': ['V', 'S'],
       'concentration': False,
       'damage': {'damage_at_slot_level': {'1': '1d4 + 1',
                                           '2': '1d4 + 1',
                                           '3': '1d4 + 1',
                                           '4': '1d4 + 1',
                                           '5': '1d4 + 1',
                                           '6': '1d4 + 1',
                                           '7': '1d4 + 1',
                                           '8': '1d4 + 1',
                                           '9': '1d4 + 1'},
                  'damage_type': {'index': 'force',
                                  'name': 'Force',
                                  'url': '/api/damage-types/force'}},
       'desc': ['You create three glowing darts of magical force. Each dart hits a '
                'creature of your choice that you can see within range. A dart deals '
                '1d4 + 1 force damage to its target. The darts all strike '
                'simultaneously, and you can direct them to hit one creature or '
       'duration': 'Instantaneous',
       'higher_level': ['When you cast this spell using a spell slot of 2nd level or '
                        'higher, the spell creates one more dart for each slot level '
                        'above 1st.'],
       'index': 'magic-missile',
       'level': 1,
       'name': 'Magic Missile',
       'range': '120 feet',
       'ritual': False,
       'school': {'index': 'evocation',
                  'name': 'Evocation',
                  'url': '/api/magic-schools/evocation'},
       'subclasses': [{'index': 'lore',
                       'name': 'Lore',
                       'url': '/api/subclasses/lore'}],
       'url': '/api/spells/magic-missile'}
    /\                                                                                      \

 Candlekeep Monk:
 "Do you need something else?"

 --> [y/n]:

Did I ever use this program? Of course not. But if you want to, the source code can be found at the GitHub repo. And remember: it’s the Bard’s fault.


Next article

A game of trades

Long time no see. I was planning to write this post quite a long time ago, but life (happily) took over. Time’s ripe now, and if I don’t write it soon I might not be able to ever click Done on that reminder. Gamification of tasks is ……

financesoftware Read more
Previous article

Sex emergence

Sex is arguably a great invention. It is, otherwise we could not acknowledge its existence across the tree of life: if sexual reproduction was not favoured by natural selection in at least some points in time and space, we would not observe it, this ……

evolutionsoftware Read more