{"id":34148279,"url":"https://github.com/plin2k/api-mocker","last_synced_at":"2026-03-11T12:49:30.523Z","repository":{"id":64998129,"uuid":"580517729","full_name":"plin2k/api-mocker","owner":"plin2k","description":"A simple API mocker is great for those who want to keep developing but backend hasn't prepared a working API yet.","archived":false,"fork":false,"pushed_at":"2023-01-27T21:08:43.000Z","size":38,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-21T10:57:46.753Z","etag":null,"topics":["api","go","http","mock","websocket"],"latest_commit_sha":null,"homepage":"","language":"Go","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/plin2k.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-20T19:01:41.000Z","updated_at":"2023-05-17T14:45:24.000Z","dependencies_parsed_at":"2023-02-15T12:46:34.801Z","dependency_job_id":null,"html_url":"https://github.com/plin2k/api-mocker","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/plin2k/api-mocker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plin2k%2Fapi-mocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plin2k%2Fapi-mocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plin2k%2Fapi-mocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plin2k%2Fapi-mocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plin2k","download_url":"https://codeload.github.com/plin2k/api-mocker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plin2k%2Fapi-mocker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30381733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","go","http","mock","websocket"],"created_at":"2025-12-15T04:42:06.005Z","updated_at":"2026-03-11T12:49:30.515Z","avatar_url":"https://github.com/plin2k.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# API Mocker\n[![Go Reference](https://pkg.go.dev/badge/github.com/plin2k/api-mocker.svg)](https://pkg.go.dev/github.com/plin2k/api-mocker)\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/plin2k/api-mocker)\n\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/plin2k/api-mocker)\n![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/plin2k/api-mocker)\n![GitHub last commit](https://img.shields.io/github/last-commit/plin2k/api-mocker)\n\n\n## Installation\n    go install github.com/plin2k/api-mocker/v2@latest\n\n### If you don't have Go\n    brew install go\n\n### If there is no brew\n    Follow instructions - https://go.dev/doc/install\n\n## Support Protocols\n    HTTP\n    WebSocket\n    gRPC - Coming soon...\n    \n## Features\n    Route grouping\n    HTTP:\n        Headers\n        Cookies\n        Methods:\n            - GET\n            - POST\n            - DELETE\n            - HEAD\n            - OPTIONS\n            - PATCH\n            - PUT\n            - ANY\n        Various responses:\n            - File\n            - Download file\n            - HTML file\n            - JSON\n            - XML\n            - TOML\n            - YAML\n            - Simple String\n    Delay before response\n    Websockets\n    Fake and random data\n    Set the maximum number of CPUs\n    Web documentation - Coming soon...\n    Authorization - Coming soon...\n    TLS - Coming soon...\n    Source file validator - Coming soon...\n    Api dublicator - Coming soon...\n    Swagger integration - Coming soon...\n\n## Example usage\n\n### Execute\n    api-mocker --help\n    api-mocker run --host=\"127.0.0.1\" --port=8080 --src=api-mocker.xml --gomaxprocs=4\n    \n### Example HTTP api-mocker.xml\n\n```xml\n\u003cxml protocol=\"http\"\u003e\n    \n    \u003cname\u003eAPI v1\u003c/name\u003e\n    \u003cdescription\u003eAPI Mocker Protocol - HTTP\u003c/description\u003e\n\n    \u003capi\u003e\n        \u003cgroup path=\"api/v1\" description=\"API v1\"\u003e\n            \n            \u003croute path=\"file\" description=\"Simple file show\" method=\"GET\" status-code=\"200\"\u003e\n                \u003cheader key=\"Content-Type\" value=\"application/xml\" description=\"my-first-header\"/\u003e\n                \u003cheader key=\"X-Referral-ID\" value=\"999\" description=\"my-second-header\"/\u003e\n                \n                \u003ccookie name=\"cookie\" description=\"my-cookie\" value=\"hello world\" max-age=\"3600\" path=\"/\" domain=\"example.com\" secure=\"true\" http-only=\"true\"/\u003e\n                \n                \u003cresponse delay=\"10\" type=\"file\" description=\"XML file\"\u003esource.xml\u003c/response\u003e\n            \u003c/route\u003e\n\n            \u003cgroup path=\"healthcheck\" description=\"Healthcheck services\"\u003e\n                \n                \u003croute path=\"mysql\" description=\"Check health status MySQL\" method=\"ANY\" status-code=\"200\"\u003e\n                    \u003cresponse type=\"json\" description=\"JSON text\"\u003e{\"status\":\"success\"}\u003c/response\u003e\n                \u003c/route\u003e\n                \n                \u003croute path=\"redis\" description=\"Check health status Redis\" method=\"ANY\" status-code=\"200\"\u003e\n                    \u003cresponse type=\"json\" description=\"JSON text\"\u003e{\"status\":\"success\"}\u003c/response\u003e\n                \u003c/route\u003e   \n                \n            \u003c/group\u003e\n        \u003c/group\u003e\n\n        \u003cgroup path=\"api/v2\" description=\"API v2\"\u003e\n            \n            \u003cheader key=\"Authorization\" value=\"{{ randJWT }}\"/\u003e\n            \n            \u003croute path=\"json\" description=\"Simple JSON show\" method=\"GET\" status-code=\"200\"\u003e\n                \n                \u003cheader key=\"Authorization\" value=\"{{ randJWT }}\" description=\"Redeclared\"/\u003e\n                \u003cheader key=\"X-Referral-ID\" value=\"999\" description=\"my-second-header\"/\u003e\n                \n                \u003cresponse type=\"json\" description=\"JSON text\"\u003e{\"name\":\"JSON\"}\u003c/response\u003e\n            \u003c/route\u003e\n        \u003c/group\u003e\n\n    \u003c/api\u003e\n    \n\u003c/xml\u003e\n```\n\n### Example WebSocket api-mocker.xml\n\n```xml\n\u003cxml protocol=\"websocket\"\u003e\n    \u003cname\u003eAPI V1\u003c/name\u003e\n    \u003cdescription\u003eAPI Mocker Protocol - WebSocket\u003c/description\u003e\n\n    \u003conopen description=\"OnOpen message\"\u003e\n        \u003cresponse delay=\"10\" type=\"text\" description=\"Can respond with message type Text and Binary\"\u003eI'm Opened a Connection\u003c/response\u003e\n    \u003c/onopen\u003e\n\n    \u003conclose description=\"OnClose message\"\u003e\n        \u003cresponse type=\"text\" description=\"Can respond with message type Text and Binary\"\u003eI'm Closed a Connection\u003c/response\u003e\n    \u003c/onclose\u003e\n\n    \u003conmessage description=\"Can accept message type Text and Binary\"\u003e\n        \u003cresponse type=\"binary\" description=\"Can respond with message type Text and Binary\"\u003eMy Reply Message\u003c/response\u003e\n    \u003c/onmessage\u003e\n\n    \u003conerror description=\"Some error has occurred\"\u003e\n        \u003cresponse type=\"text\" description=\"Can respond with message type Text and Binary\"\u003eMy Error Message\u003c/response\u003e\n    \u003c/onerror\u003e\n\n    \u003cping description=\"Reply to Ping message\"\u003e\n        \u003cresponse type=\"text\" description=\"Can respond with message type Text and Binary\"\u003ePing\u003c/response\u003e\n    \u003c/ping\u003e\n\n    \u003cpong description=\"Reply to Pong message\"\u003e\n        \u003cresponse type=\"text\" description=\"Can respond with message type Text and Binary\"\u003ePong\u003c/response\u003e\n    \u003c/pong\u003e\n\n    \u003cwhile\u003e\n        \u003cmessage delay=\"10\" count=\"10\"\u003e\n            \u003cresponse type=\"text\" description=\"Sends a message every 10 sec. Can respond with message type Text and Binary\"\u003e\n                {\"msg\":\"every 10 sec\",\"event\":\"new_chat\"}\n            \u003c/response\u003e\n        \u003c/message\u003e\n\n        \u003cmessage delay=\"3\" count=\"10\" \u003e\n            \u003cresponse type=\"text\" description=\"Sends a message every 3 sec. Can respond with message type Text and Binary\"\u003e\n                {\"msg\":\"every 3 sec\",\"event\":\"new_message\"}\n            \u003c/response\u003e\n        \u003c/message\u003e\n    \u003c/while\u003e\n\u003c/xml\u003e\n```\n\n\n### Fakers\n\n```\nRandom between dates {{ randDate \"01-01-1970\" \"01-01-2022\" }} -\u003e \"04-11-1997\"\nRandom Bool {{ randBool }} -\u003e true\nRandom String {{ randString 4 }} -\u003e \"rHdD\"\nRandom Int {{ randInt 10 20 }} -\u003e 15\nRandom Float {{ randFloat 10 1000 }} -\u003e 43.24\n        \nRandom Array Ints {{ randArrayInt 6 10 100 }} -\u003e [15,35,22,10,39,99]\nRandom Array Strings {{ randArrayString 6 3 }} -\u003e [\"deZ\",\"Zjq\",\"sdg\",\"pDp\",\"dWW\",\"WMN\"]\n\nRandom Firstname (0 - male, 1 - female) {{ randFirstName 1 }} -\u003e \"James\"\nRandom Lastname {{ randLastName }} -\u003e \"Jones\"\nRandom Sex {{ toTitle randSex }} -\u003e \"female\"\n        \nRandom Email {{ randEmail }} -\u003e \"aleksandr@kalink.in\" \nRandom Domain {{ randDomain }} -\u003e \"google.com\" \n        \nRandom Lang Code {{ randLangCode }} -\u003e \"en\"\nRandom Country {{ randCountry }} -\u003e \"Japan\" \nRandom City {{ randCity }} -\u003e \"Lefkosia\" \n        \nRandom JWT {{ randJWT }} -\u003e \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsInR5MjIyMjIyMjIyMjIyMzIzMjNwIjoiSldkc2FkYXNkYXNzYVQifQ.eyJzdWIiOiIxMjM0NWRzYWRhc2RhczY3ODkwIiwibmFtZSI6IkpvZHNhZGFzZGFzZGFzZGFzZGFzZGFzZGFzZGRzYWRhc2RobiBEb2UiLCJpYXQiOjE1MTYyMzkwMjJ9.iVsrj7dQjLvA1YUUhYUGzlnfPNS2zfUcNBi-n8rK_ls\"\nRandom Cookie {{ randCookie }} -\u003e \"id=a3fWa; Expires=Thu, 31 Oct 2021 07:28:00 GMT;\"\nRandom UUID {{ randUUID }} -\u003e \"f7ec47d0-9a7e-11ed-a8fc-0242ac120002\"\nRandom Hash (md5, sha1, sha256, sha512) {{ randHash \"sha256\" }} -\u003e \"56f3403d88c2423f711b946be61d15a7eec895635fd0e90243b6cd8526571fec\"\n\nTo Title {{ toTitle (\"hello\") }} -\u003e \"Hello\"\nTo Lower {{ toLower (\"HELLO\") }} -\u003e \"hello\"\nTo Upper {{ toUpper (\"hello\") }} -\u003e \"HELLO\"\nFormat date {{ formatDate \"01-01-2014\" }} -\u003e  Mon, 02 Jan 2006\n```\n\n### Usage Faker\n\n```xml\n\u003cxml protocol=\"http\"\u003e\n    \n    \u003cname\u003eAPI v1\u003c/name\u003e\n    \u003cdescription\u003e\n        API Mocker Protocol - HTTP. \n        Author {{ randFirstName 0 }} {{ randLastName }}\n    \u003c/description\u003e\n\n    \u003capi\u003e\n        \u003cgroup path=\"api/v{{ randInt 1 5 }}\" description=\"Root group\"\u003e\n            \u003croute path=\"json\" description=\"Simple JSON show\" method=\"GET\"\u003e\n                \u003cresponse type=\"json\" description=\"JSON text\"\u003e\n                    {\n                    \"name\":\"{{ randFirstName 1 }} {{ randLastName }}\",\n                    \"number\":{{ randInt 10 20 }},\n                    \"float\": {{ randFloat 10 1000}},\n                    \"arrayInt\": {{ randArrayInt 6 10 100 }},\n                    \"arrayString\": {{ randArrayString 6 10 }},\n                    \"randSex\": \"{{ toTitle randSex }}\",\n                    \"randDate\": \"{{ randDate \"01-01-2014\" \"01-01-2022\" }}\",\n                    \"randUUID\": \"{{ randUUID }}\",\n                    \"randHash\": \"{{ randHash \"sha256\" }}\",\n                    \"randCity\": \"{{ randCity }}\",\n                    \"randCountry\": \"{{ randCountry }}\",\n                    \"randEmail\": \"{{ randEmail }}\",\n                    \"randDomain\": \"{{ randDomain }}\",\n                    }\n                \u003c/response\u003e\n            \u003c/route\u003e\n        \u003c/group\u003e\n\n    \u003c/api\u003e\n    \n\u003c/xml\u003e\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplin2k%2Fapi-mocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplin2k%2Fapi-mocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplin2k%2Fapi-mocker/lists"}