{"_id":"@ansospace/apicraft","_rev":"2-94a4dd9a80472d2291edc430c704bee1","name":"@ansospace/apicraft","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@ansospace/apicraft","version":"0.0.1","keywords":["api","cli","http","rest","testing","mock","development","curl","postman","insomnia"],"author":{"name":"Your Name"},"license":"MIT","_id":"@ansospace/apicraft@0.0.1","maintainers":[{"name":"sahsanjay","email":"sanjay8797421521@gmail.com"}],"homepage":"https://github.com/sanjaysah101/apicraft#readme","bugs":{"url":"https://github.com/sanjaysah101/apicraft/issues"},"bin":{"apicraft":"index.js"},"dist":{"shasum":"f42e663382d451bd7870c4a300974888c819a089","tarball":"https://registry.npmjs.org/@ansospace/apicraft/-/apicraft-0.0.1.tgz","fileCount":4,"integrity":"sha512-PATng1NVsSZiIcEEJfKyUQE9zDFbqNBw5b8AIyslkJJ7edkEA5r2zfJPsSsOJmrI5uaY+4YREP1tH7FnNyIu1w==","signatures":[{"sig":"MEQCIDhauMvPKGM+G7J5GaasXsArUdxSVyE+Q15gvlO+0VXgAiBoHOI6c3/r4/4Vj6GRkaUvORQUqlvfyOyxipSX+45CEQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22844},"main":"index.js","type":"module","engines":{"node":">=18.0.0"},"gitHead":"199224ad317bac6b27d359b1462ccc79e5ab3a1e","scripts":{"lint":"echo 'No linter configured'","test":"node --test","prepublishOnly":"node scripts/count-lines.js"},"_npmUser":{"name":"sahsanjay","email":"sanjay8797421521@gmail.com"},"repository":{"url":"git+https://github.com/sanjaysah101/apicraft.git","type":"git"},"_npmVersion":"11.6.0","description":"A unified CLI for the complete API development lifecycle - from testing to mocking to code generation","directories":{},"_nodeVersion":"24.8.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/apicraft_0.0.1_1759167284491_0.45404394727527997","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@ansospace/apicraft","version":"0.0.2","description":"A unified CLI for the complete API development lifecycle - from testing to mocking to code generation","type":"module","main":"index.js","bin":{"apicraft":"index.js"},"publishConfig":{"access":"public"},"scripts":{"test":"node --test","lint":"echo 'No linter configured'","prepublishOnly":"node scripts/count-lines.js"},"keywords":["api","cli","http","rest","testing","mock","development","curl","postman","insomnia"],"author":{"name":"Your Name"},"license":"MIT","engines":{"node":">=18.0.0"},"repository":{"type":"git","url":"git+https://github.com/sanjaysah101/apicraft.git"},"bugs":{"url":"https://github.com/sanjaysah101/apicraft/issues"},"homepage":"https://github.com/sanjaysah101/apicraft#readme","_id":"@ansospace/apicraft@0.0.2","gitHead":"a79d3644ee55ae4eedc883464a85833bdaf22ff6","_nodeVersion":"24.8.0","_npmVersion":"11.6.0","dist":{"integrity":"sha512-oJrS3o7b9TDCUmx2+9dQ/4mGFbtmJLW2+Q3LfIVPdIUm5skVrhKnMeqFzFDk4u4QwCTglQ05uB7U4A5vCHZxlw==","shasum":"f63b89553f828e2705209e3797e9c38b3480eaf9","tarball":"https://registry.npmjs.org/@ansospace/apicraft/-/apicraft-0.0.2.tgz","fileCount":4,"unpackedSize":22852,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCct9ZuvPqsjqCz4Ch5kzW5dFOfBMhq1xZo0o9ewOWPjgIhANxTUFZ46OvXKhCx8jlQhFqYSCN8x1Lvjlp39rC0vLwe"}]},"_npmUser":{"name":"sahsanjay","email":"sanjay8797421521@gmail.com"},"directories":{},"maintainers":[{"name":"sahsanjay","email":"sanjay8797421521@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/apicraft_0.0.2_1759170096669_0.7811813572177002"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-29T17:34:44.376Z","modified":"2025-09-29T18:21:37.037Z","0.0.1":"2025-09-29T17:34:44.659Z","0.0.2":"2025-09-29T18:21:36.848Z"},"bugs":{"url":"https://github.com/sanjaysah101/apicraft/issues"},"author":{"name":"Your Name"},"license":"MIT","homepage":"https://github.com/sanjaysah101/apicraft#readme","keywords":["api","cli","http","rest","testing","mock","development","curl","postman","insomnia"],"repository":{"type":"git","url":"git+https://github.com/sanjaysah101/apicraft.git"},"description":"A unified CLI for the complete API development lifecycle - from testing to mocking to code generation","maintainers":[{"name":"sahsanjay","email":"sanjay8797421521@gmail.com"}],"readme":"# 🎨 Apicraft\n\n> A unified CLI for the complete API development lifecycle - from testing to mocking to code generation\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Node Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org)\n\n**apicraft** is a powerful, zero-dependency CLI tool that replaces Postman, curl, and mock servers for developers who live in the terminal. Built for the [100lines.dev](https://100lines.dev) hackathon with exactly 300 lines of JavaScript.\n\n## ✨ Features\n\n- 🚀 **HTTP Client** - Make GET, POST, PUT, DELETE, PATCH requests with beautiful formatted output\n- 🔧 **Environment Management** - Switch between dev/prod environments, use variable interpolation\n- 💾 **Request Storage** - Save and replay your favorite API requests\n- 🔄 **Code Generation** - Convert any request to fetch/axios/curl code instantly\n- 📜 **History & Replay** - Track all requests, replay any previous request\n- 🎭 **Mock Server** - Spin up instant mock APIs from JSON files\n- ⚡ **Zero Dependencies** - Only uses Node.js built-ins\n- 📦 **Git Friendly** - Version control your API configurations\n\n## 🚀 Quick Start\n\n### Installation\n\n```bash\n# Using pnpm (recommended)\npnpm install -g @ansospace/apicraft\n\n# Using npm\nnpm install -g @ansospace/apicraft\n\n# Or run directly with npx\nnpx @ansospace/apicraft <command>\n```\n\n### First Steps\n\n```bash\n# Initialize your project\napicraft init\n\n# Make your first request\napicraft get https://api.github.com/users/sanjaysah101\n\n# Set up environment variables\napicraft set baseUrl https://api.example.com\napicraft get {{baseUrl}}/users\n```\n\n## 📖 Usage\n\n### HTTP Requests\n\n```bash\n# GET request\napicraft get https://api.github.com/users/sanjaysah101\n\n# POST with JSON body\napicraft post https://api.example.com/users '{\"name\":\"John\",\"email\":\"john@example.com\"}'\n\n# PUT request\napicraft put https://api.example.com/users/1 '{\"name\":\"John Doe\"}'\n\n# DELETE request\napicraft delete https://api.example.com/users/1\n\n# PATCH request\napicraft patch https://api.example.com/users/1 '{\"name\":\"Jane\"}'\n```\n\n### Save & Run Requests\n\n```bash\n# Save a request for later\napicraft save getUser get https://api.example.com/users/1\n\n# Run a saved request\napicraft run getUser\n\n# List all saved requests\napicraft list\n```\n\n### Environment Management\n\n```bash\n# Switch environment (default: dev, prod)\napicraft env dev\n\n# Set environment variables\napicraft set baseUrl https://api.example.com\napicraft set apiKey abc123\n\n# Use variables in requests\napicraft get {{baseUrl}}/users\napicraft get https://api.example.com/data -H \"Authorization: {{apiKey}}\"\n```\n\n### Code Generation\n\n```bash\n# Make a request first\napicraft get https://api.github.com/users/sanjaysah101\n\n# Generate code from last request\napicraft generate fetch    # JavaScript fetch\napicraft generate axios    # Axios\napicraft generate curl     # cURL command\n```\n\n### History & Replay\n\n```bash\n# View recent requests\napicraft history\n\n# View last 20 requests\napicraft history 20\n\n# Replay a request from history (by index)\napicraft replay 1\n```\n\n### Mock Server\n\n```bash\n# Create mock files\nmkdir mocks\necho '{\"id\":1,\"name\":\"John Doe\"}' > mocks/GET_users_1.json\necho '{\"users\":[{\"id\":1,\"name\":\"John\"}]}' > mocks/GET_users.json\n\n# Start mock server\napicraft mock ./mocks 3000\n\n# Now access: http://localhost:3000/users/1\n```\n\n**Mock File Naming Convention:**\n\n- Format: `{METHOD}_{path}_{with}_{underscores}.json`\n- Example: `GET_users_1.json` → `GET /users/1`\n- Example: `POST_api_login.json` → `POST /api/login`\n\n## 📁 Configuration File\n\napicraft stores configuration in `.apicraft.json`:\n\n```json\n{\n  \"environments\": {\n    \"default\": {\n      \"baseUrl\": \"\",\n      \"headers\": {}\n    },\n    \"dev\": {\n      \"baseUrl\": \"http://localhost:3000\",\n      \"headers\": {\n        \"Authorization\": \"Bearer dev-token\"\n      }\n    },\n    \"prod\": {\n      \"baseUrl\": \"https://api.production.com\",\n      \"headers\": {\n        \"Authorization\": \"Bearer prod-token\"\n      }\n    }\n  },\n  \"saved\": {\n    \"getUser\": {\n      \"method\": \"get\",\n      \"url\": \"{{baseUrl}}/users/1\",\n      \"options\": {}\n    }\n  },\n  \"settings\": {\n    \"timeout\": 30000,\n    \"followRedirects\": true\n  }\n}\n```\n\n## 🎯 Use Cases\n\n### API Testing Workflow\n\n```bash\n# Set up environment\napicraft env dev\napicraft set baseUrl http://localhost:3000\n\n# Test endpoints\napicraft get {{baseUrl}}/health\napicraft post {{baseUrl}}/users '{\"name\":\"Test User\"}'\n\n# Save successful requests\napicraft save createUser post {{baseUrl}}/users '{\"name\":\"Test\"}'\n```\n\n### Frontend Development\n\n```bash\n# Start mock server while backend is being built\napicraft mock ./api-mocks 3000\n\n# Generate code for your app\napicraft get http://localhost:3000/users\napicraft generate fetch\n# Copy the generated code into your app\n```\n\n### CI/CD Integration\n\n```bash\n# Run saved health check in CI pipeline\napicraft run healthCheck || exit 1\n\n# Test API endpoints after deployment\napicraft env prod\napicraft run smokeTests\n```\n\n## 🏆 Why apicraft?\n\n| Feature | apicraft | Postman | curl | httpie |\n|---------|----------|---------|------|--------|\n| CLI Native | ✅ | ❌ | ✅ | ✅ |\n| Zero Dependencies | ✅ | N/A | ✅ | ❌ |\n| Git Friendly Config | ✅ | ❌ | ❌ | ❌ |\n| Code Generation | ✅ | ✅ | ❌ | ❌ |\n| Mock Server | ✅ | ✅ | ❌ | ❌ |\n| Request History | ✅ | ✅ | ❌ | ❌ |\n| Environment Variables | ✅ | ✅ | ❌ | ❌ |\n| Beautiful Output | ✅ | ✅ | ❌ | ✅ |\n\n## 🛠️ Development\n\n### Local Setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/yourusername/apicraft.git\ncd apicraft\n\n# Install dependencies (none! but setup pnpm)\npnpm install\n\n# Link locally for testing\nchmod +x index.js\npnpm link --global\n\n# Test it out\napicraft --help\n```\n\n### Running Locally Without Installation\n\nIf you prefer not to install globally, you can run the tool directly using Node.js:\n\n```bash\n# Clone and navigate to the project\ngit clone https://github.com/sanjaysah101/apicraft.git\ncd apicraft\n\n# Run commands directly\nnode index.js get https://api.github.com/users/sanjaysah101\nnode index.js --help\nnode index.js init\nnode index.js env dev\n```\n\n### Line Count Verification\n\n```bash\n# Count non-blank, non-comment lines\nnode scripts/count-lines.js\n```\n\n## 📝 Examples\n\n### Complete Workflow Example\n\n```bash\n# 1. Initialize project\napicraft init\n\n# 2. Configure environment\napicraft env dev\napicraft set baseUrl https://jsonplaceholder.typicode.com\n\n# 3. Make requests\napicraft get {{baseUrl}}/users/1\n\n# 4. Save useful requests\napicraft save getPost get {{baseUrl}}/posts/1\napicraft save createPost post {{baseUrl}}/posts '{\"title\":\"Test\",\"body\":\"Content\",\"userId\":1}'\n\n# 5. Generate code\napicraft generate fetch\n\n# 6. Check history\napicraft history\n\n# 7. Replay a request\napicraft replay 1\n```\n\n### Mock Server Example\n\n```bash\n# Create mock structure\nmkdir -p mocks/api\necho '{\"status\":\"healthy\"}' > mocks/GET_health.json\necho '{\"users\":[]}' > mocks/GET_api_users.json\necho '{\"id\":1,\"name\":\"John\"}' > mocks/GET_api_users_1.json\n\n# Start server\napicraft mock ./mocks 4000\n\n# Test endpoints\ncurl http://localhost:4000/health\ncurl http://localhost:4000/api/users\ncurl http://localhost:4000/api/users/1\n```\n\n## 🤝 Contributing\n\nThis project was built for the 100lines.dev hackathon with a strict 300-line limit. While the core is feature-complete, contributions for documentation, examples, and bug fixes are welcome!\n\n## 📄 License\n\nMIT © @ansospace/apicraft\n\n## 🏅 Hackathon\n\nBuilt for [CLI Line-Limit Hackathon 2025](https://100lines.dev) - September 26-29, 2025\n\n**Line Count:** 300 lines (JavaScript)\n**Challenge:** Every Line Counts\n\n---\n\n<div align=\"center\">\n  <strong>Made with ❤️ for developers who love the terminal</strong>\n</div>\n","readmeFilename":"README.md"}