Package: dnd5epy
openapi-clientIntroductionWelcome to the dnd5eapi, the Dungeons & Dragons 5th Edition API!
This documentation should help you familiarize yourself with the resources
available and how to consume them with HTTP requests. Read through the getting
started section before you dive in. Most of your problems should be solved
just by reading through it.Getting StartedLet's make our first API request to the D&D 5th Edition API!Open up a terminal and usecurlorhttpieto make an API request for a resource. You can also scroll through the
definitions below and send requests directly from the endpoint documentation!For example, if you paste and run thiscurlcommand:curl-XGET\"https://www.dnd5eapi.co/api/ability-scores/cha\"-H\"Accept:application/json\"We should see a result containing details about the Charisma ability score:{\"index\":\"cha\",\"name\":\"CHA\",\"full_name\":\"Charisma\",\"desc\":[\"Charismameasuresyourabilitytointeracteffectivelywithothers.Itincludessuchfactorsasconfidenceandeloquence,anditcanrepresentacharmingorcommandingpersonality.\",\"ACharismacheckmightarisewhenyoutrytoinfluenceorentertainothers,whenyoutrytomakeanimpressionortellaconvincinglie,orwhenyouarenavigatingatrickysocialsituation.TheDeception,Intimidation,Performance,andPersuasionskillsreflectaptitudeincertainkindsofCharismachecks.\"],\"skills\":[{\"name\":\"Deception\",\"index\":\"deception\",\"url\":\"/api/skills/deception\"},{\"name\":\"Intimidation\",\"index\":\"intimidation\",\"url\":\"/api/skills/intimidation\"},{\"name\":\"Performance\",\"index\":\"performance\",\"url\":\"/api/skills/performance\"},{\"name\":\"Persuasion\",\"index\":\"persuasion\",\"url\":\"/api/skills/persuasion\"}],\"url\":\"/api/ability-scores/cha\"}AuthenticationThe dnd5eapi is a completely open API. No authentication is required to query
and get data. This also means that we've limited what you can do to justGET-ing the data. If you find a mistake in the data, feel free tomessage us.GraphQLThis API supportsGraphQL. The GraphQL URL for this API
ishttps://www.dnd5eapi.co/graphql. Most of your questions regarding the GraphQL schema can be answered
by querying the endpoint with the Apollo sandbox explorer.SchemasDefinitions of all schemas will be accessible in a future update. Two of the most common schemas are described here.APIReferenceRepresents a minimal representation of a resource. The detailed representation of the referenced resource can be retrieved by making a request to the referencedURL.APIReference {
  index     string
  name      string
  url       string
}DCRepresents a difficulty check.DC {
  dc_type       APIReference
  dc_value      number
  success_type  \"none\" | \"half\" | \"other\"
}DamageRepresents damage.Damage {
  damage_type     APIReference
  damage_dice     string
}ChoiceRepresents a choice made by a player. Commonly seen related to decisions made during character creation or combat (e.g.: the description of the cleric class, underProficiencies, states "Skills: Choose two from History, Insight, Medicine, Persuasion, and Religion"[SRD p15])Choice {
  desc      string
  choose    number
  type      string
  from      OptionSet
}OptionSetThe OptionSet structure provides the options to be chosen from, or sufficient data to fetch and interpret the options. All OptionSets have anoption_set_typeattribute that indicates the structure of the object that contains the options. The possible values areoptions_array,equipment_category, andreference_list. Other attributes on the OptionSet depend on the value of this attribute.options_arrayoptions(array): An array of Option objects. Each item in the array represents an option that can be chosen.equipment_categoryequipment_category(APIReference): A reference to an EquipmentCategory. Each item in the EquipmentCategory'sequipmentarray represents one option that can be chosen.resource_listresource_list_url(string): A reference (by URL) to a collection in the database. The URL may include query parameters. Each item in the resulting ResourceList'sresultsarray represents one option that can be chosen.OptionWhen the options are given in anoptions_array, each item in the array inherits from the Option structure. All Options have anoption_typeattribute that indicates the structure of the option. The value of this attribute indicates how the option should be handled, and each type has different attributes. The possible values and their corresponding attributes are listed below.reference- A terminal option. Contains a reference to a Document that can be added to the list of options chosen.item(APIReference): A reference to the chosen item.action- A terminal option. Contains information describing an action, for use within Multiattack actions.action_name(string): The name of the action, according to itsnameattribute.count(number | string): The number of times this action can be repeated if this option is chosen.type(string =\"melee\" | \"ranged\" | \"ability\" | \"magic\", optional): For attack actions that can be either melee, ranged, abilities, or magic.multiple- When this option is chosen, all of its child options are chosen, and must be resolved the same way as a normal option.items(array): An array of Option objects. All of them must be taken if the option is chosen.choice- A nested choice. If this option is chosen, the Choice structure contained within must be resolved like a normal Choice structure, and the results are the chosen options.choice(Choice): The Choice to resolve.string- A terminal option. Contains a reference to a string.string(string): The string.ideal- A terminal option. Contains information about an ideal.desc(string): A description of the ideal.alignments(ApiReference[]): A list of alignments of those who might follow the ideal.counted_reference- A terminal option. Contains a reference to something else in the API along with a count.count(number): Count.of(ApiReference): Thing being referenced.score_prerequisite- A terminal option. Contains a reference to an ability score and a minimum score.ability_score(ApiReference): Ability score being referenced.minimum_score(number): The minimum score required to satisfy the prerequisite.ability_bonus- A terminal option. Contains a reference to an ability score and a bonusability_score(ApiReference): Ability score being referencedbonus(number): The bonus being applied to the ability scorebreath- A terminal option: Contains a reference to information about a breath attack.name(string): Name of the breath.dc(DC): Difficulty check of the breath attack.damage([Damage]): Damage dealt by the breath attack, if any.damage- A terminal option. Contains information about damage.damage_type(ApiReference): Reference to type of damage.damage_dice(string): Damage expressed in dice (e.g. "13d6").notes(string): Information regarding the damage.FAQWhat is the SRD?The SRD, or Systems Reference Document, contains guidelines for publishing content under the OGL. This allows for some of the data for D&D 5e to be open source. The API only covers data that can be found in the SRD.Here's a link to the full text of the SRD.What is the OGL?The Open Game License (OGL) is a public copyright license by Wizards of the Coast that may be used by tabletop role-playing game developers to grant permission to modify, copy, and redistribute some of the content designed for their games, notably game mechanics. However, they must share-alike copies and derivative works.More information about the OGL can be found here.A monster, spell, subclass, etc. is missing from the API / Database. Can I add it?Please check if the data is within the SRD. If it is, feel free to open an issue or PR to add it yourself. Otherwise, due to legal reasons, we cannot add it.Can this API be self hosted?Yes it can! You can also host the data yourself if you don't want to use the API at all. You can also make changes and add extra data if you like. However, it is up to you to merge in new changes to the data and API.Can I publish is on ? Is this free use?Yes, you can. The API itself is under theMIT license, and the underlying data accessible via the API is supported under the SRD and OGL.Status PageThe status page for the API can be found here:https://5e-bits.github.io/dnd-uptime/ChatCome hang out with uson Discord!ContributeThis API is built from two repositories.The repo containing the data lives here:https://github.com/bagelbits/5e-databaseThe repo with the API implementation lives here:https://github.com/bagelbits/5e-srd-apiThis is a evolving API and having fresh ideas are always welcome! You can
open an issue in either repo, open a PR for changes, or just discuss with
other users in this discord.This Python package is automatically generated by theOpenAPI Generatorproject:API version: 0.1Package version: 1.0.0Build package: org.openapitools.codegen.languages.PythonClientCodegen
For more information, please visithttps://github.com/5e-bitsRequirements.Python 3.7+Installation & Usagepip installIf the python package is hosted on a repository, you can install directly using:pipinstallgit+https://github.com/GIT_USER_ID/GIT_REPO_ID.git(you may need to runpipwith root permission:sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)Then import the package:importdnd5epySetuptoolsInstall viaSetuptools.pythonsetup.pyinstall--user(orsudo python setup.py installto install the package for all users)Then import the package:importdnd5epyTestsExecutepytestto run the tests.Getting StartedPlease follow theinstallation procedureand then run the following:importtimeimportdnd5epyfromdnd5epy.restimportApiExceptionfrompprintimportpprint# Defining the host is optional and defaults to https://www.dnd5eapi.co# See configuration.py for a list of all supported configuration parameters.configuration=dnd5epy.Configuration(host="https://www.dnd5eapi.co")# Enter a context with an instance of the API clientwithdnd5epy.ApiClient(configuration)asapi_client:# Create an instance of the API classapi_instance=dnd5epy.CharacterDataApi(api_client)index='cha'# str | The `index` of the ability score to get.try:# Get an ability score by index.api_response=api_instance.api_ability_scores_index_get(index)print("The response of CharacterDataApi->api_ability_scores_index_get:\n")pprint(api_response)exceptApiExceptionase:print("Exception when calling CharacterDataApi->api_ability_scores_index_get:%s\n"%e)Documentation for API EndpointsAll URIs are relative tohttps://www.dnd5eapi.coClassMethodHTTP requestDescriptionCharacterDataApiapi_ability_scores_index_getGET/api/ability-scores/{index}Get an ability score by index.CharacterDataApiapi_alignments_index_getGET/api/alignments/{index}Get an alignment by index.CharacterDataApiapi_backgrounds_index_getGET/api/backgrounds/{index}Get a background by index.CharacterDataApiapi_languages_index_getGET/api/languages/{index}Get a language by index.CharacterDataApiapi_proficiencies_index_getGET/api/proficiencies/{index}Get a proficiency by index.CharacterDataApiapi_skills_index_getGET/api/skills/{index}Get a skill by index.ClassApiapi_classes_index_getGET/api/classes/{index}Get a class by index.ClassApiapi_classes_index_multi_classing_getGET/api/classes/{index}/multi-classingGet multiclassing resource for a class.ClassApiapi_classes_index_spellcasting_getGET/api/classes/{index}/spellcastingGet spellcasting info for a class.ClassLevelsApiapi_classes_index_levels_class_level_features_getGET/api/classes/{index}/levels/{class_level}/featuresGet features available to a class at the requested level.ClassLevelsApiapi_classes_index_levels_class_level_getGET/api/classes/{index}/levels/{class_level}Get level resource for a class and level.ClassLevelsApiapi_classes_index_levels_getGET/api/classes/{index}/levelsGet all level resources for a class.ClassLevelsApiapi_classes_index_levels_spell_level_spells_getGET/api/classes/{index}/levels/{spell_level}/spellsGet spells of the requested level available to the class.ClassResourceListsApiapi_classes_index_features_getGET/api/classes/{index}/featuresGet features available for a class.ClassResourceListsApiapi_classes_index_proficiencies_getGET/api/classes/{index}/proficienciesGet proficiencies available for a class.ClassResourceListsApiapi_classes_index_spells_getGET/api/classes/{index}/spellsGet spells available for a class.ClassResourceListsApiapi_classes_index_subclasses_getGET/api/classes/{index}/subclassesGet subclasses available for a class.CommonApiapi_endpoint_getGET/api/{endpoint}Get list of all available resources for an endpoint.CommonApiapi_getGET/apiGet all resource URLs.EquipmentApiapi_equipment_categories_index_getGET/api/equipment-categories/{index}Get an equipment category by index.EquipmentApiapi_equipment_index_getGET/api/equipment/{index}Get an equipment item by index.EquipmentApiapi_magic_items_index_getGET/api/magic-items/{index}Get a magic item by index.EquipmentApiapi_weapon_properties_index_getGET/api/weapon-properties/{index}Get a weapon property by index.FeatsApiapi_feats_index_getGET/api/feats/{index}Get a feat by index.FeaturesApiapi_features_index_getGET/api/features/{index}Get a feature by index.GameMechanicsApiapi_conditions_index_getGET/api/conditions/{index}Get a condition by index.GameMechanicsApiapi_damage_types_index_getGET/api/damage-types/{index}Get a damage type by index.GameMechanicsApiapi_magic_schools_index_getGET/api/magic-schools/{index}Get a magic school by index.MonstersApiapi_monsters_getGET/api/monstersGet list of monsters with optional filteringMonstersApiapi_monsters_index_getGET/api/monsters/{index}Get monster by index.RacesApiapi_races_index_getGET/api/races/{index}Get a race by index.RacesApiapi_races_index_proficiencies_getGET/api/races/{index}/proficienciesGet proficiencies available for a race.RacesApiapi_races_index_subraces_getGET/api/races/{index}/subracesGet subraces available for a race.RacesApiapi_races_index_traits_getGET/api/races/{index}/traitsGet traits available for a race.RulesApiapi_rule_sections_index_getGET/api/rule-sections/{index}Get a rule section by index.RulesApiapi_rules_index_getGET/api/rules/{index}Get a rule by index.SpellsApiapi_spells_getGET/api/spellsGet list of spells with optional filtering.SpellsApiapi_spells_index_getGET/api/spells/{index}Get a spell by index.SubclassesApiapi_subclasses_index_features_getGET/api/subclasses/{index}/featuresGet features available for a subclass.SubclassesApiapi_subclasses_index_getGET/api/subclasses/{index}Get a subclass by index.SubclassesApiapi_subclasses_index_levels_getGET/api/subclasses/{index}/levelsGet all level resources for a subclass.SubclassesApiapi_subclasses_index_levels_subclass_level_features_getGET/api/subclasses/{index}/levels/{subclass_level}/featuresGet features of the requested spell level available to the class.SubclassesApiapi_subclasses_index_levels_subclass_level_getGET/api/subclasses/{index}/levels/{subclass_level}Get level resources for a subclass and level.SubracesApiapi_subraces_index_getGET/api/subraces/{index}Get a subrace by index.SubracesApiapi_subraces_index_proficiencies_getGET/api/subraces/{index}/proficienciesGet proficiences available for a subrace.SubracesApiapi_subraces_index_traits_getGET/api/subraces/{index}/traitsGet traits available for a subrace.TraitsApiapi_traits_index_getGET/api/traits/{index}Get a trait by index.Documentation For ModelsAPIReferenceAPIReferenceListAbilityBonusAbilityScoreAlignmentAreaOfEffectArmorBackgroundBackgroundAllOfFeatureChoiceClassAllOfStartingEquipmentClassLevelClassLevelClassSpecificClassLevelClassSpecificAnyOfClassLevelClassSpecificAnyOf1ClassLevelClassSpecificAnyOf10ClassLevelClassSpecificAnyOf11ClassLevelClassSpecificAnyOf2ClassLevelClassSpecificAnyOf3ClassLevelClassSpecificAnyOf4ClassLevelClassSpecificAnyOf5ClassLevelClassSpecificAnyOf5MartialArtsClassLevelClassSpecificAnyOf6ClassLevelClassSpecificAnyOf7ClassLevelClassSpecificAnyOf8ClassLevelClassSpecificAnyOf9ClassLevelClassSpecificAnyOf9CreatingSpellSlotsInnerConditionCostDCDamageDamageAtCharacterLevelDamageAtSlotLevelDamageTypeEquipmentEquipmentCategoryEquipmentPackErrorResponseFeatFeatureFeatureAllOfPrerequisitesInnerFeatureAllOfPrerequisitesInnerAnyOfFeatureAllOfPrerequisitesInnerAnyOf1FeatureAllOfPrerequisitesInnerAnyOf2GearLanguageMagicItemMagicItemAllOfRarityMagicSchoolModelClassMonsterMonsterAbilityMonsterActionMonsterAllOfSensesMonsterAllOfSpeedMonsterArmorClassMonsterArmorClassOneOfMonsterArmorClassOneOf1MonsterArmorClassOneOf2MonsterArmorClassOneOf3MonsterArmorClassOneOf4MonsterAttackMonsterMultiAttackActionMonsterProficiencyMonsterSenseMonsterSpecialAbilityMonsterSpellMonsterSpellcastingMonsterUsageMulticlassingOptionOptionOneOfOptionOneOf1OptionOneOf10OptionOneOf2OptionOneOf3OptionOneOf4OptionOneOf5OptionOneOf6OptionOneOf7OptionOneOf8OptionOneOf9OptionSetOptionSetOneOfOptionSetOneOf1OptionSetOneOf2PrerequisitePrerequisiteAbilityScoreProficiencyProficiencyAllOfReferenceRaceResourceDescriptionRuleRuleSectionSkillSpellSpellAllOfDamageSpellPrerequisiteSpellcastingSpellcastingInfoInnerSpellcastingSpellcastingAbilitySubclassSubclassAllOfSpellsSubclassLevelSubclassLevelResourceSubclassLevelSpellcastingSubraceSubraceAllOfRaceTraitTraitAllOfTraitSpecificTraitAllOfTraitSpecificOneOfTraitAllOfTraitSpecificOneOfBreathWeaponTraitAllOfTraitSpecificOneOfBreathWeaponDamageTraitAllOfTraitSpecificOneOfBreathWeaponUsageTraitAllOfTraitSpecificOneOfDamageTypeWeaponWeaponAllOfRangeWeaponPropertyDocumentation For AuthorizationEndpoints do not require authorization.Author