{"library":"protagonist","title":"Protagonist API Blueprint Parser","description":"Protagonist is a Node.js wrapper that provides programmatic access to Drafter, the high-performance C++ API Blueprint parser. It enables developers to validate and parse API Blueprint documents, a specialized Markdown dialect for describing web APIs, directly within Node.js applications. The current stable version, 2.3.0, integrates with Drafter 5.1.0, offering features like asynchronous and synchronous parsing and validation with configurable options, such as requiring a blueprint name. While it offers direct integration with the powerful Drafter engine, its reliance on `node-gyp` for compilation of native C++ addons during installation means it requires specific build toolchains (Python 2.7, C++ compiler) on the host system. This differentiates it from the simpler-to-install `drafter-npm` package, which provides pre-built binaries and is often recommended for general use, making Protagonist suitable for environments where direct compilation or specific Drafter version control is preferred.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install protagonist"],"cli":null},"imports":["const protagonist = require('protagonist');","const protagonist = require('protagonist');\nconst parseResult = await protagonist.parse(source);","const protagonist = require('protagonist');\nconst parseResult = await protagonist.validate(source, options);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const protagonist = require('protagonist');\n\nconst blueprint = `# My API\\n\\n## Group Users\\n\\n### User [/users/{id}]\\n+ Parameters\\n    + id: 1 (number, required) - The ID of the user.\\n\\n#### Retrieve a User [GET]\\n+ Response 200 (application/json)\\n    + Body\\n        { \"id\": 1, \"name\": \"John Doe\" }\\n`;\n\nasync function parseAndLog() {\n  try {\n    const parseResult = await protagonist.parse(blueprint, { requireBlueprintName: false });\n    console.log(JSON.stringify(parseResult, null, 2));\n  } catch (error) {\n    console.error('Parsing failed:', error);\n  }\n}\n\nparseAndLog();","lang":"javascript","description":"Demonstrates asynchronous parsing of a basic API Blueprint document and logs the structured result, disabling the `requireBlueprintName` option for this example.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}