{"id":13686636,"url":"https://github.com/getapid/apid","last_synced_at":"2025-05-01T09:32:22.059Z","repository":{"id":40454243,"uuid":"203925674","full_name":"getapid/apid","owner":"getapid","description":"User focused API testing","archived":true,"fork":false,"pushed_at":"2022-08-25T06:14:05.000Z","size":1590,"stargazers_count":89,"open_issues_count":3,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-11-12T09:48:51.465Z","etag":null,"topics":["api","apid","assertions","cli","docker","rest","testing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/getapid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-23T04:47:06.000Z","updated_at":"2024-01-04T10:07:06.000Z","dependencies_parsed_at":"2022-07-16T09:30:57.085Z","dependency_job_id":null,"html_url":"https://github.com/getapid/apid","commit_stats":null,"previous_names":["getapid/apid-cli","getapid/cli"],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getapid%2Fapid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getapid%2Fapid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getapid%2Fapid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getapid%2Fapid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/getapid","download_url":"https://codeload.github.com/getapid/apid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251852860,"owners_count":21654476,"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","apid","assertions","cli","docker","rest","testing"],"created_at":"2024-08-02T15:00:36.513Z","updated_at":"2025-05-01T09:32:21.792Z","avatar_url":"https://github.com/getapid.png","language":"Go","readme":"# User Focused API testing\n\n## 🔭 What is APId?\n\nAPId is a framework that lets you write declarative, end-to-end collections of requests and make sure your API behaves the way you expect.\n\n## ⬇️ Installation\n\nAPId comes in both binary packages and docker image. You can find the docker image [here](https://github.com/getapid/apid/pkgs/container/apid), while the binaries can be found [here](https://github.com/getapid/apid/releases)\n\nHere's how to install the latest binary on UNIX based systems:\n\n```sh\n# make sure to substitute the URL with the correct platform for you\ncurl -L https://github.com/getapid/apid/releases/latest/download/apid-darwin-arm64 -o /tmp/apid\nchmod +x /tmp/apid\nsudo mv /tmp/apid /usr/local/bin/apid\n\n# test if the installation was successful \napid version\n```\n\n### ✅ A simple test\n\nAPId tests, or specs, are written in `jsonnet`. There are a number of built-in useful functions to make it easier to make and validate requests to your API.\n\n```jsonnet\n// contents of `example.jsonnet`\n\n{\n  simple_spec: spec([\n    {\n      name: \"google homepage\",\n      request: {\n        method: \"GET\",\n        url: \"https://www.google.com/\"\n      },\n      expect: {\n        code: 200\n      }\n    }\n  ])\n}\n```\n\nAnd to run the test\n\n```bash\n\u003e apid check -s \"example.jsonnet\"\n\nexample::simple_spec\n    google homepage\n        + status code is 200\n\nspecs passed: 1\nspecs failed: 0\n```\n\nSuccess! You've just written your first APId test! If you change the `expect.code` from `200` to lets say `500` the test will fail and this will be the output:\n\n```bash\n\u003e apid check -s \"example.jsonnet\"\n\nexample::simple_spec\n    google homepage\n        o status code: wanted 500, got 200  \n\nspecs passed: 0\nspecs failed: 1\n```\n\nFor more examples please check the [`examples`](examples) folder in this repository.\n\n## 📚 Documentation\n\nYou can find the most up to date documentation [`here`](docs)\n\n## Patterns\n\nJsonnet is a very powerful language which can be utilised to make your life easier.\n\n### Split variables from tests\n\nFor example you can extract any variables in a separate file\n\n```js\n// vars.libsonnet\n{\n  url: 'http://localhost:8080',\n}\n\n// test.jsonnet\n{\n    name: 'request',\n    request: {\n        url: vars.url,\n    },\n    expect: {\n        code: 200,\n    },\n},\n```\n\n### Store matchers in variables\n\nYou can extract your matchers in a local variable to make the test easier to read\n\n```js\n// test.jsonnet\nlocal key_matcher = key(\n    or([\n        regex(\"\\\\w+\"),\n        regex(\"\\\\d+\"),\n    ])\n);\n\n{\n    body: {\n        [key_matcher]: \"the value of that key\" // note the [] around the key, ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#computed_property_names\n    }\n}\n```\n\n\n## ⁉️ Help\n\nIf you have any questions or ideas please feel free to head over to the [discussion](https://github.com/getapid/apid/discussions) tab in this repository and ask away!\n\n### 💻 CLI\n\n1. Head to the [latest release](https://github.com/getapid/apid/releases/latest) and select the binary for your operating system.\n2. Once downloaded open the archive and place the executable in a directory on your `$PATH`.\n\n## 👽 Contributing\n\nTo contribute to APId, please see [CONTRIBUTING](CONTRIBUTING.md).\n","funding_links":[],"categories":["docker"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetapid%2Fapid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgetapid%2Fapid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetapid%2Fapid/lists"}