### Install Project Dependencies Source: https://github.com/5e-bits/docs/blob/main/README.md Run this command to install all necessary project dependencies using yarn. ```bash $ yarn ``` -------------------------------- ### Start Local Development Server Source: https://github.com/5e-bits/docs/blob/main/README.md Starts a local development server for live preview. Changes are reflected without server restart. ```bash $ yarn start ``` -------------------------------- ### Install Axios for HTTP Requests Source: https://github.com/5e-bits/docs/blob/main/docs/tutorials/advanced/monster-search-with-javascript.mdx Installs the Axios library, which is used for making HTTP requests in the JavaScript code. ```bash npm install axios ``` -------------------------------- ### Fetch Ability Score with cURL/httpie Source: https://github.com/5e-bits/docs/blob/main/docs/tutorials/beginner/getting-started.mdx Use cURL or httpie to make a GET request to the API for ability score details. Ensure your tool is installed and accessible in your terminal. ```bash curl -X GET "https://www.dnd5eapi.co/api/ability-scores/cha" -H "Accept: application/json" ``` ```bash http dnd5eapi.co/api/ability-scores/cha ``` -------------------------------- ### Get Race Details Source: https://context7.com/5e-bits/docs/llms.txt Retrieves race information including ability bonuses, traits, and languages. Use this endpoint to get all details for a specific race. ```bash curl "https://www.dnd5eapi.co/api/2014/races/elf" ``` -------------------------------- ### Serve Application Locally Source: https://github.com/5e-bits/docs/blob/main/docs/tutorials/advanced/monster-search-with-javascript.mdx Starts a simple local server to test the web application. Access the application via http://localhost:5000 in your browser. ```bash npx serve ``` -------------------------------- ### Example API Response for Dwarf Race Source: https://github.com/5e-bits/docs/blob/main/docs/tutorials/basic/discover-dnd-races-with-shell-scripting.mdx This is an example JSON output from the D&D 5e API when requesting details for the 'dwarf' race. It includes information such as ability bonuses, alignment, age, and size. ```json { "index": "dwarf", "name": "Dwarf", "speed": 25, "ability_bonuses": [ { "ability_score": { "index": "con", "name": "CON", "url": "/api/ability-scores/con" }, "bonus": 2 } ], "alignment": "Most dwarves are lawful, believing firmly in the benefits of a well-ordered society. They tend toward good as well, with a strong sense of fair play and a belief that everyone deserves to share in the benefits of a just order.", "age": "Dwarves mature at the same rate as humans, but they're considered young until they reach the age of 50. On average, they live about 350 years.", "size": "Medium", "size_description": "Dwarves stand between 4 and 5 feet tall and average about 150 pounds. Your size is Medium.", ... ... } ``` -------------------------------- ### Get Class Details Source: https://context7.com/5e-bits/docs/llms.txt Retrieve comprehensive data for a character class, such as Barbarian, including hit die, proficiencies, starting equipment, and available subclasses. ```bash curl "https://www.dnd5eapi.co/api/2014/classes/barbarian" ``` -------------------------------- ### API Response Example (Charisma) Source: https://github.com/5e-bits/docs/blob/main/docs/tutorials/beginner/getting-started.mdx This is an example of the JSON response you will receive when querying for the Charisma ability score. It includes the score's index, name, description, and associated skills. ```json { "index": "cha", "name": "CHA", "full_name": "Charisma", "desc": [ "Charisma measures your ability to interact effectively with others. It includes such factors as confidence and eloquence, and it can represent a charming or commanding personality.", "A Charisma check might arise when you try to influence or entertain others, when you try to make an impression or tell a convincing lie, or when you are navigating a tricky social situation. The Deception, Intimidation, Performance, and Persuasion skills reflect aptitude in certain kinds of Charisma checks." ], "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" } ``` -------------------------------- ### Get Resource List Source: https://context7.com/5e-bits/docs/llms.txt Retrieve a paginated list of all resources for a given endpoint, including the total count and basic reference information for each item. ```bash curl "https://www.dnd5eapi.co/api/2014/classes" ``` -------------------------------- ### Get Spell Details Source: https://context7.com/5e-bits/docs/llms.txt Retrieves comprehensive spell information. Use this endpoint to get all details for a specific spell. ```bash curl "https://www.dnd5eapi.co/api/2014/spells/fireball" ``` -------------------------------- ### Get Game Rules Source: https://context7.com/5e-bits/docs/llms.txt Retrieves rule descriptions and subsections from the SRD. ```APIDOC ## GET /api/2014/rules/{rule_name} ### Description Retrieves rule descriptions and subsections from the SRD for a specific rule. ### Method GET ### Endpoint /api/2014/rules/{rule_name} ### Parameters #### Path Parameters - **rule_name** (string) - Required - The name of the rule to retrieve (e.g., "combat"). ### Request Example ```bash curl "https://www.dnd5eapi.co/api/2014/rules/combat" ``` ### Response #### Success Response (200) - **index** (string) - The index of the rule. - **name** (string) - The name of the rule. - **desc** (string) - The description of the rule, potentially in markdown format. - **subsections** (array) - An array of subsection objects, each containing `index`, `name`, and `url`. - **url** (string) - The API URL for this rule resource. #### Response Example ```json { "index": "combat", "name": "Combat", "desc": "# Combat\n\nA typical combat encounter is a clash between two sides...", "subsections": [ { "index": "the-order-of-combat", "name": "The Order of Combat", "url": "/api/2014/rule-sections/the-order-of-combat" }, { "index": "movement-and-position", "name": "Movement and Position", "url": "/api/2014/rule-sections/movement-and-position" }, { "index": "actions-in-combat", "name": "Actions in Combat", "url": "/api/2014/rule-sections/actions-in-combat" } ], "url": "/api/2014/rules/combat" } ``` ``` -------------------------------- ### Example Response for a Specific Locale Source: https://github.com/5e-bits/docs/blob/main/docs/reference/multilingual.md This JSON object represents the details of a specific supported locale, including its language code and URL. ```json { "lang": "de", "url": "/api/2014/locales/de" } ``` -------------------------------- ### GraphQL Endpoint and Example Query Source: https://github.com/5e-bits/docs/blob/main/docs/graphql.md The GraphQL endpoint allows for flexible data retrieval using GraphQL queries. Below is the endpoint URL and an example query to fetch ability scores. ```APIDOC ## GraphQL API ### Description This API supports GraphQL for flexible data retrieval. You can query the API using GraphQL syntax. ### Endpoint `https://www.dnd5eapi.co/graphql/2014` ### Example Queries #### Get a list of ability scores ```graphql query { abilityScores { name desc skills { name } } } ``` ### Request Example (GraphQL queries are sent as the request body, typically with a `query` field) ```json { "query": "query { abilityScores { name desc skills { name } } }" } ``` ### Response Example (Success - 200) ```json { "data": { "abilityScores": [ { "name": "Strength", "desc": "...", "skills": [ { "name": "Athletics" } ] }, { "name": "Dexterity", "desc": "...", "skills": [ { "name": "Acrobatics" }, { "name": "Sleight of Hand" }, { "name": "Stealth" } ] } // ... other ability scores ] } } ``` ``` -------------------------------- ### Example Response for Supported Locales Source: https://github.com/5e-bits/docs/blob/main/docs/reference/multilingual.md This JSON structure shows the count of supported locales and a list of available language codes with their corresponding URLs. ```json { "count": 2, "results": [ { "lang": "de", "url": "/api/2014/locales/de" }, { "lang": "fr", "url": "/api/2014/locales/fr" } ] } ``` -------------------------------- ### Get Class Details Source: https://context7.com/5e-bits/docs/llms.txt Retrieves comprehensive details for a specific character class, including hit die, proficiencies, starting equipment, and subclasses. ```APIDOC ## GET /api/2014/classes/{index} ### Description Retrieves comprehensive information about a character class including hit die, proficiencies, starting equipment, and subclasses. ### Method GET ### Endpoint https://www.dnd5eapi.co/api/2014/classes/{index} ### Parameters #### Path Parameters - **index** (string) - Required - The index of the class (e.g., `barbarian`, `wizard`). ### Response #### Success Response (200) - **index** (string) - The index of the class. - **name** (string) - The name of the class. - **hit_die** (integer) - The hit die value for the class. - **class_levels** (string) - The URL to retrieve level progression details for this class. - **proficiencies** (array of objects) - A list of proficiencies granted by the class. - **index** (string) - The index of the proficiency. - **name** (string) - The name of the proficiency. - **url** (string) - The API endpoint for the proficiency. - **saving_throws** (array of objects) - A list of ability scores the class has saving throw proficiency in. - **index** (string) - The index of the ability score. - **name** (string) - The name of the ability score. - **url** (string) - The API endpoint for the ability score. - **starting_equipment** (array of objects) - A list of starting equipment options for the class. - **equipment** (object) - Details of the equipment. - **index** (string) - The index of the equipment. - **name** (string) - The name of the equipment. - **quantity** (integer) - The number of items. - **subclasses** (array of objects) - A list of subclasses available for this class. - **index** (string) - The index of the subclass. - **name** (string) - The name of the subclass. - **url** (string) - The API endpoint for the subclass. - **url** (string) - The API endpoint for this class. ### Response Example ```json { "index": "barbarian", "name": "Barbarian", "hit_die": 12, "class_levels": "/api/2014/classes/barbarian/levels", "proficiencies": [ { "index": "light-armor", "name": "Light Armor", "url": "/api/2014/proficiencies/light-armor" }, { "index": "medium-armor", "name": "Medium Armor", "url": "/api/2014/proficiencies/medium-armor" }, { "index": "shields", "name": "Shields", "url": "/api/2014/proficiencies/shields" } ], "saving_throws": [ { "index": "str", "name": "STR", "url": "/api/2014/ability-scores/str" }, { "index": "con", "name": "CON", "url": "/api/2014/ability-scores/con" } ], "starting_equipment": [ { "equipment": { "index": "explorers-pack", "name": "Explorer's Pack" }, "quantity": 1 }, { "equipment": { "index": "javelin", "name": "Javelin" }, "quantity": 4 } ], "subclasses": [ { "index": "berserker", "name": "Berserker", "url": "/api/2014/subclasses/berserker" } ], "url": "/api/2014/classes/barbarian" } ``` ``` -------------------------------- ### Get Equipment Details using cURL Source: https://context7.com/5e-bits/docs/llms.txt Retrieve detailed information about a specific piece of equipment by its index. This includes cost, weight, and damage or armor class if applicable. ```bash curl "https://www.dnd5eapi.co/api/2014/equipment/longsword" ``` -------------------------------- ### Get Game Rules - Combat Source: https://context7.com/5e-bits/docs/llms.txt Retrieves rule descriptions and subsections for combat. Use this endpoint to fetch detailed information about combat mechanics. ```bash curl "https://www.dnd5eapi.co/api/2014/rules/combat" ``` -------------------------------- ### Get Equipment Details Source: https://context7.com/5e-bits/docs/llms.txt Retrieves specific details about a piece of equipment, such as its cost, weight, and damage (for weapons) or armor class (for armor). ```APIDOC ## GET /api/2014/equipment/{index} ### Description Retrieves equipment information including cost, weight, damage (for weapons), and armor class (for armor). ### Method GET ### Endpoint /api/2014/equipment/{index} ### Parameters #### Path Parameters - **index** (string) - Required - The unique identifier for the equipment. ### Request Example ```bash curl "https://www.dnd5eapi.co/api/2014/equipment/longsword" ``` ### Response #### Success Response (200) - **index** (string) - The equipment's index. - **name** (string) - The equipment's name. - **equipment_category** (object) - The category the equipment belongs to. - **weapon_category** (string) - The category of the weapon (if applicable). - **weapon_range** (string) - The range of the weapon (if applicable). - **category_range** (string) - The category range of the weapon (if applicable). - **cost** (object) - The cost of the equipment. - **weight** (number) - The weight of the equipment. - **damage** (object) - Damage details for weapons. - **two_handed_damage** (object) - Two-handed damage details for weapons. - **properties** (array) - Properties of the weapon. - **url** (string) - The API URL for this equipment. #### Response Example ```json { "index": "longsword", "name": "Longsword", "equipment_category": { "index": "weapon", "name": "Weapon" }, "weapon_category": "Martial", "weapon_range": "Melee", "category_range": "Martial Melee", "cost": { "quantity": 15, "unit": "gp" }, "weight": 3, "damage": { "damage_dice": "1d8", "damage_type": { "index": "slashing", "name": "Slashing" } }, "two_handed_damage": { "damage_dice": "1d10", "damage_type": { "index": "slashing", "name": "Slashing" } }, "properties": [ { "index": "versatile", "name": "Versatile", "url": "/api/2014/weapon-properties/versatile" } ], "url": "/api/2014/equipment/longsword" } ``` ``` -------------------------------- ### Get Race Details Source: https://context7.com/5e-bits/docs/llms.txt Retrieves race information including ability bonuses, traits, languages, and available subraces. ```APIDOC ## GET /api/2014/races/{index} ### Description Retrieves race information including ability bonuses, traits, languages, and available subraces. ### Method GET ### Endpoint /api/2014/races/{index} ### Parameters #### Path Parameters - **index** (string) - Required - The unique identifier for the race. ### Request Example ```bash curl "https://www.dnd5eapi.co/api/2014/races/elf" ``` ### Response #### Success Response (200) - **index** (string) - The race's index. - **name** (string) - The race's name. - **speed** (integer) - The base walking speed of the race. - **size** (string) - The size category of the race (e.g., Medium, Small). - **ability_bonuses** (array) - An array of ability score bonuses granted by the race. - **age** (string) - A description of the race's typical lifespan and aging process. - **alignment** (string) - A description of the race's typical alignment tendencies. - **languages** (array) - An array of languages the race can speak. - **traits** (array) - An array of racial traits the race possesses. - **subraces** (array) - An array of subraces available for this race. - **url** (string) - The API endpoint for this race. #### Response Example ```json { "index": "elf", "name": "Elf", "speed": 30, "size": "Medium", "ability_bonuses": [ { "ability_score": { "index": "dex", "name": "DEX" }, "bonus": 2 } ], "age": "Although elves reach physical maturity at about the same age as humans...", "alignment": "Elves love freedom, variety, and self-expression...", "languages": [ { "index": "common", "name": "Common" }, { "index": "elvish", "name": "Elvish" } ], "traits": [ { "index": "darkvision", "name": "Darkvision", "url": "/api/2014/traits/darkvision" }, { "index": "fey-ancestry", "name": "Fey Ancestry", "url": "/api/2014/traits/fey-ancestry" }, { "index": "trance", "name": "Trance", "url": "/api/2014/traits/trance" } ], "subraces": [ { "index": "high-elf", "name": "High Elf", "url": "/api/2014/subraces/high-elf" } ], "url": "/api/2014/races/elf" } ``` ``` -------------------------------- ### Get Monster Details Source: https://context7.com/5e-bits/docs/llms.txt Retrieves a complete monster stat block. Use this endpoint to get all details for a specific monster. ```bash curl "https://www.dnd5eapi.co/api/2014/monsters/aboleth" ``` -------------------------------- ### Get All Available Endpoints Source: https://context7.com/5e-bits/docs/llms.txt Use this endpoint to discover all available API endpoints. It returns a JSON object mapping resource types to their respective URLs. ```bash curl "https://www.dnd5eapi.co/api/2014" ``` -------------------------------- ### Get Magic Item Details using cURL Source: https://context7.com/5e-bits/docs/llms.txt Fetch details for a magic item using its index. This provides information such as rarity, description, and equipment category. ```bash curl "https://www.dnd5eapi.co/api/2014/magic-items/adamantine-armor" ``` -------------------------------- ### Get Resource List Source: https://context7.com/5e-bits/docs/llms.txt Fetches a paginated list of all resources for a specific endpoint, including the total count and basic reference information for each item. ```APIDOC ## GET /api/2014/{resource} ### Description Returns a paginated list of all resources available at a given endpoint with count and basic reference information. ### Method GET ### Endpoint https://www.dnd5eapi.co/api/2014/{resource} ### Parameters #### Path Parameters - **resource** (string) - Required - The name of the resource to list (e.g., `classes`, `monsters`). ### Response #### Success Response (200) - **count** (integer) - The total number of resources available. - **results** (array) - An array of resource objects. - **index** (string) - The unique identifier for the resource. - **name** (string) - The display name of the resource. - **url** (string) - The API endpoint for the specific resource. ### Response Example ```json { "count": 12, "results": [ { "index": "barbarian", "name": "Barbarian", "url": "/api/2014/classes/barbarian" }, { "index": "bard", "name": "Bard", "url": "/api/2014/classes/bard" }, { "index": "cleric", "name": "Cleric", "url": "/api/2014/classes/cleric" } ] } ``` ``` -------------------------------- ### Get Ability Score Details Source: https://context7.com/5e-bits/docs/llms.txt Fetch detailed information about a specific ability score (e.g., Charisma), including its full name, description, and associated skills. ```bash curl "https://www.dnd5eapi.co/api/2014/ability-scores/cha" ``` -------------------------------- ### Get Condition Details Source: https://context7.com/5e-bits/docs/llms.txt Retrieves information about status conditions that can affect creatures. ```APIDOC ## GET /api/2014/conditions/{condition_name} ### Description Retrieves detailed information about a specific status condition affecting creatures in the game. ### Method GET ### Endpoint /api/2014/conditions/{condition_name} ### Parameters #### Path Parameters - **condition_name** (string) - Required - The name of the condition to retrieve (e.g., "blinded"). ### Request Example ```bash curl "https://www.dnd5eapi.co/api/2014/conditions/blinded" ``` ### Response #### Success Response (200) - **index** (string) - The index of the condition. - **name** (string) - The name of the condition. - **desc** (array) - An array of strings, where each string describes an aspect of the condition's effects. - **url** (string) - The API URL for this condition resource. #### Response Example ```json { "index": "blinded", "name": "Blinded", "desc": [ "- A blinded creature can't see and automatically fails any ability check that requires sight.", "- Attack rolls against the creature have advantage, and the creature's attack rolls have disadvantage." ], "url": "/api/2014/conditions/blinded" } ``` ``` -------------------------------- ### GraphQL - Get All Monsters with Armor Class Source: https://context7.com/5e-bits/docs/llms.txt Efficiently retrieve the name, index, and armor class details for all monsters in a single request, solving the N+1 query problem. ```APIDOC ## GraphQL Query: Get All Monsters with Armor Class ### Description Efficiently fetch specific fields from all monsters in a single request, solving the N+1 query problem. ### Method POST ### Endpoint /graphql/2014 ### Request Body (GraphQL Query) ```graphql query Monsters { monsters { name index armor_class { value type } } } ``` ### Response Example *Response includes all 334 monsters with only the requested fields.* ```json { "data": { "monsters": [ { "name": "Aboleth", "index": "aboleth", "armor_class": [ { "value": 17, "type": "natural" } ] }, // ... more monsters ] } } ``` ``` -------------------------------- ### Get Condition Details - Blinded Source: https://context7.com/5e-bits/docs/llms.txt Retrieves information about the 'blinded' status condition. This endpoint is useful for understanding the effects of conditions on creatures. ```bash curl "https://www.dnd5eapi.co/api/2014/conditions/blinded" ``` -------------------------------- ### Get All Available Endpoints Source: https://context7.com/5e-bits/docs/llms.txt Retrieves a list of all available API endpoints, useful for discovering the API's structure and available resources. ```APIDOC ## GET /api/2014 ### Description Returns an object containing all available API endpoint URLs, allowing discovery of the complete API structure. ### Method GET ### Endpoint https://www.dnd5eapi.co/api/2014 ### Response #### Success Response (200) - **index** (string) - The name of the resource. - **url** (string) - The API endpoint for the resource. ### Response Example ```json { "ability-scores": "/api/2014/ability-scores", "alignments": "/api/2014/alignments", "classes": "/api/2014/classes", "conditions": "/api/2014/conditions", "equipment": "/api/2014/equipment", "monsters": "/api/2014/monsters", "races": "/api/2014/races", "spells": "/api/2014/spells" } ``` ``` -------------------------------- ### GraphQL - Get All Ability Scores Source: https://context7.com/5e-bits/docs/llms.txt Use GraphQL to query specific fields from all ability scores in a single request, optimizing data retrieval. ```APIDOC ## GraphQL Query: Get All Ability Scores ### Description Use GraphQL to query exactly the fields you need from the API with a single request. ### Method POST ### Endpoint /graphql/2014 ### Request Body (GraphQL Query) ```graphql query { abilityScores { name desc skills { name } } } ``` ### Response Example ```json { "data": { "abilityScores": [ { "name": "STR", "desc": ["Strength measures bodily power..."], "skills": [{ "name": "Athletics" }] }, { "name": "DEX", "desc": ["Dexterity measures agility..."], "skills": [{ "name": "Acrobatics" }, { "name": "Sleight of Hand" }, { "name": "Stealth" }] }, ... ] } } ``` ``` -------------------------------- ### Get Spell Details Source: https://context7.com/5e-bits/docs/llms.txt Retrieves comprehensive spell information including components, duration, damage scaling, and class availability. ```APIDOC ## GET /api/2014/spells/{index} ### Description Retrieves comprehensive spell information including components, duration, damage scaling, and class availability. ### Method GET ### Endpoint /api/2014/spells/{index} ### Parameters #### Path Parameters - **index** (string) - Required - The unique identifier for the spell. ### Request Example ```bash curl "https://www.dnd5eapi.co/api/2014/spells/fireball" ``` ### Response #### Success Response (200) - **index** (string) - The spell's index. - **name** (string) - The spell's name. - **level** (integer) - The spell's level. - **school** (object) - The school of magic the spell belongs to. - **casting_time** (string) - The time required to cast the spell. - **range** (string) - The range of the spell. - **components** (array) - An array of spell component types (V, S, M). - **material** (string) - The material component description, if applicable. - **duration** (string) - The duration of the spell's effect. - **concentration** (boolean) - Whether the spell requires concentration. - **ritual** (boolean) - Whether the spell can be cast as a ritual. - **desc** (array) - An array of strings describing the spell's effect. - **higher_level** (array) - An array of strings describing the spell's effect at higher levels. - **damage** (object) - Information about the spell's damage, if applicable. - **classes** (array) - An array of classes that can learn the spell. - **url** (string) - The API endpoint for this spell. #### Response Example ```json { "index": "fireball", "name": "Fireball", "level": 3, "school": { "index": "evocation", "name": "Evocation" }, "casting_time": "1 action", "range": "150 feet", "components": ["V", "S", "M"], "material": "A tiny ball of bat guano and sulfur.", "duration": "Instantaneous", "concentration": false, "ritual": false, "desc": [ "A bright streak flashes from your pointing finger to a point you choose..." ], "higher_level": [ "When you cast this spell using a spell slot of 4th level or higher, the damage increases by 1d6 for each slot level above 3rd." ], "damage": { "damage_type": { "index": "fire", "name": "Fire" }, "damage_at_slot_level": { "3": "8d6", "4": "9d6", "5": "10d6", "6": "11d6", "7": "12d6", "8": "13d6", "9": "14d6" } }, "classes": [ { "index": "sorcerer", "name": "Sorcerer" }, { "index": "wizard", "name": "Wizard" } ], "url": "/api/2014/spells/fireball" } ``` ``` -------------------------------- ### Get Magic Item Details Source: https://context7.com/5e-bits/docs/llms.txt Retrieves detailed information about a specific magic item, including its rarity, description, and associated equipment category. ```APIDOC ## GET /api/2014/magic-items/{index} ### Description Retrieves magic item information including rarity, description, and equipment category. ### Method GET ### Endpoint /api/2014/magic-items/{index} ### Parameters #### Path Parameters - **index** (string) - Required - The unique identifier for the magic item. ### Request Example ```bash curl "https://www.dnd5eapi.co/api/2014/magic-items/adamantine-armor" ``` ### Response #### Success Response (200) - **index** (string) - The magic item's index. - **name** (string) - The magic item's name. - **equipment_category** (object) - The category the magic item belongs to. - **rarity** (object) - The rarity of the magic item. - **desc** (array) - A description of the magic item. - **variants** (array) - Any variants of the magic item. - **variant** (boolean) - Indicates if the item is a variant. - **url** (string) - The API URL for this magic item. #### Response Example ```json { "index": "adamantine-armor", "name": "Adamantine Armor", "equipment_category": { "index": "armor", "name": "Armor" }, "rarity": { "name": "Uncommon" }, "desc": [ "Armor (medium or heavy, but not hide), uncommon", "This suit of armor is reinforced with adamantine, one of the hardest substances in existence. While you're wearing it, any critical hit against you becomes a normal hit." ], "variants": [], "variant": false, "url": "/api/2014/magic-items/adamantine-armor" } ``` ``` -------------------------------- ### Get All Class Spells using cURL Source: https://context7.com/5e-bits/docs/llms.txt Retrieve a list of all spells available to a specific class by querying the API with the class index. ```bash curl "https://www.dnd5eapi.co/api/2014/classes/wizard/spells" ``` -------------------------------- ### Get List of Ability Scores Source: https://github.com/5e-bits/docs/blob/main/docs/graphql.md Use this query to retrieve a list of all ability scores, including their descriptions and associated skills. This is a foundational query for exploring character attributes. ```graphql query { abilityScores { name desc skills { name } } } ``` -------------------------------- ### Get Class Level Information Source: https://context7.com/5e-bits/docs/llms.txt Access level-specific progression details for a class, like the Barbarian at level 1, including features, ability score bonuses, and proficiencies. ```bash curl "https://www.dnd5eapi.co/api/2014/classes/barbarian/levels/1" ``` -------------------------------- ### Get Ability Score Details Source: https://context7.com/5e-bits/docs/llms.txt Retrieves detailed information about a specific ability score, including its full name, description, and associated skills. ```APIDOC ## GET /api/2014/ability-scores/{index} ### Description Retrieves details about one of the six ability scores (STR, DEX, CON, INT, WIS, CHA) including descriptions and related skills. ### Method GET ### Endpoint https://www.dnd5eapi.co/api/2014/ability-scores/{index} ### Parameters #### Path Parameters - **index** (string) - Required - The index of the ability score (e.g., `str`, `dex`, `cha`). ### Response #### Success Response (200) - **index** (string) - The index of the ability score. - **name** (string) - The abbreviated name of the ability score (e.g., "CHA"). - **full_name** (string) - The full name of the ability score (e.g., "Charisma"). - **desc** (array of strings) - A description of the ability score. - **skills** (array of objects) - A list of skills associated with this ability score. - **index** (string) - The index of the skill. - **name** (string) - The name of the skill. - **url** (string) - The API endpoint for the skill. - **url** (string) - The API endpoint for this ability score. ### Response Example ```json { "index": "cha", "name": "CHA", "full_name": "Charisma", "desc": [ "Charisma measures your ability to interact effectively with others..." ], "skills": [ { "index": "deception", "name": "Deception", "url": "/api/2014/skills/deception" }, { "index": "intimidation", "name": "Intimidation", "url": "/api/2014/skills/intimidation" }, { "index": "performance", "name": "Performance", "url": "/api/2014/skills/performance" }, { "index": "persuasion", "name": "Persuasion", "url": "/api/2014/skills/persuasion" } ], "url": "/api/2014/ability-scores/cha" } ``` ``` -------------------------------- ### Example German Spell Translation Entry Source: https://github.com/5e-bits/docs/blob/main/docs/reference/multilingual.md This JSON structure demonstrates how to contribute translations by providing only the translatable fields for a specific entry. Non-translatable fields are automatically sourced from the English base. ```json [ { "index": "acid-arrow", "name": "Säurepfeil", "desc": [ "Ein glitzernder grüner Pfeil schießt auf ein Ziel..." ], "higher_level": [ "Wenn du diesen Zauber mit einem Zauberplatz der 3. Stufe oder höher wirkst..." ] } ] ``` -------------------------------- ### Fetch D&D Dwarf Race Info with cURL Source: https://github.com/5e-bits/docs/blob/main/docs/tutorials/basic/discover-dnd-races-with-shell-scripting.mdx Use cURL to make a GET request to the D&D 5e API for dwarf race details. Ensure the 'Accept' header is set to 'application/json' for a JSON response. ```bash curl -L 'https://www.dnd5eapi.co/api/races/dwarf' -H 'Accept: application/json' ``` -------------------------------- ### GraphQL - Get Monster with Specific Fields Source: https://context7.com/5e-bits/docs/llms.txt Fetch a single monster's data, requesting only the necessary fields to reduce bandwidth and response size. ```APIDOC ## GraphQL Query: Get Monster with Specific Fields ### Description Fetch a single monster with only the fields you need, reducing bandwidth and response size. ### Method POST ### Endpoint /graphql/2014 ### Request Body (GraphQL Query) ```graphql query Monster($index: String) { monster(index: $index) { name challenge_rating hit_points armor_class { value type } actions { name desc attack_bonus } } } ``` ### Variables ```json { "index": "aboleth" } ``` ### Response Example ```json { "data": { "monster": { "name": "Aboleth", "challenge_rating": 10, "hit_points": 135, "armor_class": [{ "value": 17, "type": "natural" }], "actions": [ { "name": "Multiattack", "desc": "The aboleth makes three tentacle attacks.", "attack_bonus": null }, { "name": "Tentacle", "desc": "Melee Weapon Attack: +9 to hit...", "attack_bonus": 9 } ] } } } ``` ``` -------------------------------- ### Fetch All Spell Data from API Source: https://github.com/5e-bits/docs/blob/main/docs/tutorials/advanced/react-spell-cards.mdx Fetches all spell data from the D&D 5e API. This function first retrieves a list of spell indexes and then makes individual requests for each spell to get full details. It's useful for populating a spell list. ```javascript const BASE_URL = "https://www.dnd5eapi.co"; export async function getAllSpells() { const spellIndexes = await fetch(BASE_URL + "/api/spells").then((response) => response.json() ); return Promise.all( spellIndexes.results.map((index) => fetch(BASE_URL + index.url).then((response) => response.json()) ) ); } ``` -------------------------------- ### Initialize Node.js Project Source: https://github.com/5e-bits/docs/blob/main/docs/tutorials/advanced/monster-search-with-javascript.mdx Initializes a new Node.js project. Run this in your project's root directory. ```bash npm init -y ``` -------------------------------- ### Build Static Website Content Source: https://github.com/5e-bits/docs/blob/main/README.md Generates static website content into the 'build' directory, ready for hosting. ```bash $ yarn build ``` -------------------------------- ### Deploy Website using SSH Source: https://github.com/5e-bits/docs/blob/main/README.md Deploys the website using SSH. This command builds the site and pushes to the 'gh-pages' branch. ```bash $ USE_SSH=true yarn deploy ``` -------------------------------- ### OptionSet Schema Source: https://github.com/5e-bits/docs/blob/main/docs/reference/schemas.md Provides the options to be chosen from, or sufficient data to fetch and interpret the options. ```APIDOC ## OptionSet Schema ### Description Provides the options to be chosen from, or sufficient data to fetch and interpret the options. ### Fields - **option_set_type** (string) - Indicates the structure of the object that contains the options. Possible values: `options_array`, `equipment_category`, `resource_list`. ### Option Set Types #### options_array - **options** (array): An array of Option objects. #### equipment_category - **equipment_category** (APIReference): A reference to an EquipmentCategory. #### resource_list - **resource_list_url** (string): A reference (by URL) to a collection in the database. ``` -------------------------------- ### Deploy Website without SSH Source: https://github.com/5e-bits/docs/blob/main/README.md Deploys the website without using SSH. Replace placeholder with your GitHub username. ```bash $ GIT_USER= yarn deploy ``` -------------------------------- ### Get Class Spells Source: https://context7.com/5e-bits/docs/llms.txt Retrieves a list of all spells available to a specific character class. ```APIDOC ## GET /api/2014/classes/{class}/spells ### Description Retrieves all spells available to a specific class. ### Method GET ### Endpoint /api/2014/classes/{class}/spells ### Parameters #### Path Parameters - **class** (string) - Required - The name or index of the class. ### Request Example ```bash curl "https://www.dnd5eapi.co/api/2014/classes/wizard/spells" ``` ### Response #### Success Response (200) - **count** (integer) - The total number of spells available. - **results** (array) - A list of spells, each with index, name, URL, and level. #### Response Example ```json { "count": 204, "results": [ { "index": "acid-splash", "name": "Acid Splash", "url": "/api/2014/spells/acid-splash", "level": 0 }, { "index": "alarm", "name": "Alarm", "url": "/api/2014/spells/alarm", "level": 1 }, ... ] } ``` ``` -------------------------------- ### Get Spells by Spell Level for a Class Source: https://context7.com/5e-bits/docs/llms.txt Retrieves spells of a specific level that are available to a given character class. ```APIDOC ## GET /api/2014/classes/{class}/levels/{level}/spells ### Description Retrieves spells of a specific level that are available to a class. ### Method GET ### Endpoint /api/2014/classes/{class}/levels/{level}/spells ### Parameters #### Path Parameters - **class** (string) - Required - The name or index of the class. - **level** (integer) - Required - The spell level to retrieve (0-9). ### Request Example ```bash curl "https://www.dnd5eapi.co/api/2014/classes/wizard/levels/3/spells" ``` ### Response #### Success Response (200) - **count** (integer) - The total number of spells at the specified level. - **results** (array) - A list of spells, each with index, name, and URL. #### Response Example ```json { "count": 24, "results": [ { "index": "animate-dead", "name": "Animate Dead", "url": "/api/2014/spells/animate-dead" }, { "index": "bestow-curse", "name": "Bestow Curse", "url": "/api/2014/spells/bestow-curse" }, ... ] } ``` ``` -------------------------------- ### Get a specific locale Source: https://github.com/5e-bits/docs/blob/main/docs/reference/multilingual.md This endpoint retrieves details for a specific locale. It returns a 404 error if no translations exist for the requested language. ```APIDOC ## Get a specific locale ### Description Returns details for a specific locale. Returns `404` if no translations exist for the requested language. ### Method GET ### Endpoint `/api/{year}/locales/{lang}` ### Parameters #### Path Parameters - **lang** (string) - Required - The language code (e.g., `de`, `fr`). ### Response Example (Success - 200) ```json { "lang": "de", "url": "/api/2014/locales/de" } ``` ``` -------------------------------- ### Load and Render Spells in App Component Source: https://github.com/5e-bits/docs/blob/main/docs/tutorials/advanced/react-spell-cards.mdx Fetches all spells when the component mounts and renders them as a list. Requires the `getAllSpells` function from the API. ```jsx import { useEffect, useState } from "react"; import { getAllSpells } from "./api"; import "./styles.css"; export default function App() { const [spells, setSpells] = useState([]); useEffect(() => { getAllSpells().then(setSpells); }, []); return (
); } ```