{"id":13632163,"url":"https://github.com/4lejandrito/fetchbook","last_synced_at":"2025-03-17T10:07:20.614Z","repository":{"id":198787405,"uuid":"699677037","full_name":"4lejandrito/fetchbook","owner":"4lejandrito","description":"Run and test your HTTP requests. Git friendly, 100% local.","archived":false,"fork":false,"pushed_at":"2023-10-21T18:03:19.000Z","size":255,"stargazers_count":151,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-11T09:57:40.275Z","etag":null,"topics":["api-client","bun","cli","http-client","htttp-request","testing","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/4lejandrito.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"4lejandrito","custom":["https://buymeacoffee.com/b4iusc3"]}},"created_at":"2023-10-03T05:45:35.000Z","updated_at":"2025-02-10T05:20:50.000Z","dependencies_parsed_at":"2023-10-12T02:33:51.764Z","dependency_job_id":"4a2b7c62-984e-4cd1-9b43-af75a95bfa4e","html_url":"https://github.com/4lejandrito/fetchbook","commit_stats":null,"previous_names":["4lejandrito/fetchbook"],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4lejandrito%2Ffetchbook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4lejandrito%2Ffetchbook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4lejandrito%2Ffetchbook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4lejandrito%2Ffetchbook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4lejandrito","download_url":"https://codeload.github.com/4lejandrito/fetchbook/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244014136,"owners_count":20383715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","bun","cli","http-client","htttp-request","testing","typescript"],"created_at":"2024-08-01T22:02:54.094Z","updated_at":"2025-03-17T10:07:20.569Z","avatar_url":"https://github.com/4lejandrito.png","language":"TypeScript","funding_links":["https://github.com/sponsors/4lejandrito","https://buymeacoffee.com/b4iusc3"],"categories":["TypeScript"],"sub_categories":[],"readme":"# Fetchbook [![npm version](https://img.shields.io/npm/v/fetchbook.svg?style=flat)](https://www.npmjs.com/package/fetchbook)\n\nFetchbook is a command-line tool designed to help you manage your collections of HTTP requests. It is based on the standard [RequestInit](https://fetch.spec.whatwg.org/#requestinit) object, and runs in TypeScript with [bun.sh](https://bun.sh/).\n\nYou can try it out just by running this command:\n\n```bash\nnpx fetchbook run --demo -v\n```\n\n\u003e [!WARNING]\n\u003e :construction_worker_woman: Fetchbook is currently under active development, expect breaking changes.\n\n## Installation\n\nTo use Fetchbook in you own project:\n\n```bash\nnpx fetchbook init\n```\n\nTo create a separate Fetchbook project:\n\n```bash\nnpx fetchbook init \u003cproject name\u003e\n```\n\nAlternatively, you can install it manually:\n\n```bash\nnpm install fetchbook\n```\n\n## Usage\n\nFetchbook is split in different commands that operate on one or multiple [fetch story files](#fetch-story-files).\n\n### Run\n\n```bash\nfetchbook run [story] [options]\n```\n\nRun one or many [fetch story files](#fetch-story-files).\n\n#### Demo\n\n```bash\nnpx fetchbook run --demo -v\n```\n\n#### Arguments\n\n- `[story]` (optional): Path to a [fetch story file](#fetch-story-files) (or folder) that describes an HTTP request. If omitted, Fetchbook will prompt you to search and choose a fetch story in the current folder.\n\n#### Options\n\n- `-a, --all`: Run all [fetch story files](#fetch-story-files) in the current folder recursively.\n- `-v, --verbose`: Enable verbose output, providing additional information about the request and response.\n- `-d, --dry-run`: Perform a dry run, simulating the request without making an actual HTTP call.\n\n#### Examples\n\n1. Run a single [fetch story file](#fetch-story-files):\n\n   ```bash\n   fetchbook run path/to/your/story.fetch.ts\n   ```\n\n2. Run all [fetch story files](#fetch-story-files) in the current folder and its subfolders:\n\n   ```bash\n   fetchbook run -a\n   ```\n\n3. Perform a dry run of a [fetch story file](#fetch-story-files):\n\n   ```bash\n   fetchbook run path/to/your/story.fetch.ts -d\n   ```\n\n4. Run a [fetch story file](#fetch-story-files) with verbose output:\n\n   ```bash\n   fetchbook run path/to/your/story.fetch.ts -v\n   ```\n\n### Export\n\n```bash\nfetchbook export [story] [options]\n```\n\nExport a [fetch story file](#fetch-story-files) as other formats (now only `curl` is supported) and display it in the terminal instead of making the HTTP request.\n\n#### Demo\n\n```bash\nnpx fetchbook export --format=curl --demo -a\n```\n\n#### Arguments\n\n- `[story]` (optional): Path to a [fetch story file](#fetch-story-files) (or folder) that describes an HTTP request. If omitted, Fetchbook will prompt you to search and choose a fetch story in the current folder.\n\n#### Options\n\n- `-f, --format`: Export the request as a cURL command and display it in the terminal instead of making the HTTP request.\n- `-a, --all`: Export all [fetch story files](#fetch-story-files) in the current folder recursively.\n\n#### Examples\n\n1. Export a single [fetch story file](#fetch-story-files) as a cURL command:\n\n   ```bash\n   fetchbook export --format curl path/to/your/story.fetch.ts\n   ```\n\n2. Export all [fetch story files](#fetch-story-files) in the current folder and its subfolders:\n\n   ```bash\n   fetchbook export --format curl -a\n   ```\n\n### Init\n\n```bash\nnpx fetchbook init [name]\n```\n\nInitialize a fetchbook project.\n\n#### Arguments\n\n- `[name]` (optional): Name of the project. If set Fetchbook will create a new folder with a `package.json` file and a bunch of sample [fetch story files](#fetch-story-files). If not set Fetchbook will initialize an existing project.\n\n#### Examples\n\n1. Run a single [fetch story file](#fetch-story-files):\n\n   ```bash\n   npx fetchbook init my-fetchbook-project\n   ```\n\n## Fetch Story Files\n\nFetch story files are TypeScript modules ending with `.fetch.ts` that must comply with the following type definition:\n\n```typescript\ntype FetchStory = {\n  name: string;\n  url: string;\n  init: RequestInit;\n  expect?: Partial\u003c{\n    status: number;\n    statusText: string;\n    headers: Record\u003cstring, string\u003e;\n    body: any;\n  }\u003e;\n  before?: FetchStory[];\n  after?: FetchStory[];\n};\n```\n\nHere's an explanation of each property within the `FetchStory` type definition:\n\n- `name` (string): A descriptive name for the story, helping you identify and organize your requests.\n- `url` (string): The URL of the HTTP request.\n- `init` ([RequestInit](https://fetch.spec.whatwg.org/#requestinit)): An object containing the request's initialization options, including method, headers, and body.\n- `expect` (optional): Defines your expectations for the response, such as expected HTTP status code, status text, headers and body.\n- `before` (optional): An array of `FetchStory` objects representing requests to execute before the main request.\n- `after` (optional): An array of `FetchStory` objects representing requests to execute after the main request.\n\n### Example Fetch Story File\n\nHere's an example of a Fetchbook fetch story file adhering to the TypeScript definition and the naming convention (ending with `.fetch.ts`):\n\n```typescript\n// examples/venusaur.fetch.ts\nimport { FetchStory } from \"fetchbook\";\n\nexport default {\n  name: \"Get info about Venusaur\",\n  url: \"https://pokeapi.co/api/v2/pokemon/venusaur\",\n  init: {\n    method: \"GET\",\n  },\n  expect: {\n    status: 200,\n    headers: {\n      \"content-type\": \"application/json; charset=utf-8\",\n    },\n    body: {\n      order: 3,\n      name: \"venusaur\",\n      height: 20,\n      weight: 1000,\n    },\n  },\n} satisfies FetchStory;\n```\n\nEnsure that your story files adhere to this structure, type definition, and the naming convention (`.fetch.ts`) to work seamlessly with Fetchbook. You can create multiple fetch story files to describe different HTTP requests and use Fetchbook to manage and execute them as needed.\n\n## Contributing\n\nContributions are welcome! These are some of the current pending tasks:\n\n- [ ] Print response body by default to mimic a standard cURL request.\n- [ ] Add command to create a story: `fetchbook create`.\n- [ ] Add command to import a story from other formats: `fetchbook import`.\n- [ ] Add a command to start a web ui: `fetchbook studio`.\n\n## License\n\nFetchbook is licensed under the MIT License. Feel free to use and modify it according to your needs.\n\n---\n\nEnjoy using Fetchbook for efficient HTTP request management! If you encounter any issues or have suggestions for improvement, please don't hesitate to [open an issue](https://github.com/4lejandrito/fetchbook/issues/new) or contribute to the project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4lejandrito%2Ffetchbook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4lejandrito%2Ffetchbook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4lejandrito%2Ffetchbook/lists"}