{"id":15464601,"url":"https://github.com/blakewilson/jres","last_synced_at":"2026-02-07T20:32:08.169Z","repository":{"id":42813441,"uuid":"223801724","full_name":"blakewilson/jres","owner":"blakewilson","description":"The Jres specification establishes how to format JSON RESTful API responses.","archived":false,"fork":false,"pushed_at":"2023-01-06T07:46:02.000Z","size":921,"stargazers_count":1,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-02T10:53:38.815Z","etag":null,"topics":["api","http1-1","json","rest"],"latest_commit_sha":null,"homepage":"https://jres.dev","language":"JavaScript","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/blakewilson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-24T19:57:36.000Z","updated_at":"2020-06-03T07:24:09.000Z","dependencies_parsed_at":"2023-02-05T16:00:25.089Z","dependency_job_id":null,"html_url":"https://github.com/blakewilson/jres","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/blakewilson/jres","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakewilson%2Fjres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakewilson%2Fjres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakewilson%2Fjres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakewilson%2Fjres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blakewilson","download_url":"https://codeload.github.com/blakewilson/jres/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakewilson%2Fjres/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29208161,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T20:13:33.422Z","status":"ssl_error","status_checked_at":"2026-02-07T20:13:31.455Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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","http1-1","json","rest"],"created_at":"2024-10-02T00:40:41.077Z","updated_at":"2026-02-07T20:32:08.152Z","avatar_url":"https://github.com/blakewilson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[\u003cimg width=\"200px\" height=\"200px\" style=\"display: block; margin-top: 1.25rem; margin-left: auto; margin-right: auto\" src=\"https://jres.dev/logo.svg\"\u003e](https://jres.dev)\n\n# The Jres Specification\n\n## Introduction\n\nThe Jres specification establishes how to format JSON RESTful API responses.\n\nThe specification assumes that there is always either a `data` key, or an `error` key. Both can not be present. If the response contains the `data` key, the API request has succeeded. If the `error` key is present, the API request did not succeed. All responses are enveloped.\n\n## Examples\n\n### Successful Responses\n\n| Key | Is Required | Description |\n| --- | --- | --- |\n| `data` | \u0026#10004; | Holds the API payload |\n\nA successful response is only required to have a `data` key. This will hold the API response's payload. If there is no payload, like in the case of a record deletion, `data` would be set to `null`.\n\n#### GET /users\n\n```json\n{\n  \"data\": [\n    {\n      \"id\": 1,\n      \"firstName\": \"Jane\",\n      \"lastName\": \"Doe\",\n      \"email\": \"janedoe@example.com\"\n    },\n    {\n      \"id\": 2,\n      \"firstName\": \"John\",\n      \"lastName\": \"Doe\",\n      \"email\": \"johndoe@example.com\"\n    },\n    {...},\n    {...}\n  ]\n}\n```\n\n#### GET /users/:userId\n\n```json\n{\n  \"data\": {\n    \"id\": 1,\n    \"firstName\": \"Jane\",\n    \"lastName\": \"Doe\",\n    \"email\": \"janedoe@example.com\"\n  }\n}\n```\n\n#### DELETE /users/:userId\n\n\u003e `data` can be `null` if the response does not have a payload, like a DELETE endpoint.\n\n```json\n{\n  \"data\": null\n}\n```\n\n### Unsuccessful Responses\n\n| Key | Is Required | Description |\n| --- | --- | --- |\n| `error` | \u0026#10004; | The `error` object key is used to determine if the response was successful or not. |\n| `error.message` | \u0026#10004; | The `error.message` key is a UI friendly message that can be used on the client side to describe the error. | \n| `error.code` | | A code that can be used to describe a specific error within your application. This is different than a [status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes). |\n| `error.validationErrors` | | If your error is due to incorrect input, use `error.validationErrors`. This key stores an object such that the keys are the [HTML id](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id) of the invalid field, and the value is the error message to be displayed on the client side. |\n\nAn unsuccessful response will always include an `error` key. That way, you can check if your response succeeds or not by simply checking if the `error` key is in the response. Here is an example in JavaScript:\n\n```js\nfetch(`/users/`, {\n  method: 'GET'\n})\n  .then(res =\u003e res.json())\n  .then(res =\u003e {\n    // Check for error in response.\n    if(res.error) {\n      throw error\n    }\n\n    // API Request succeeded, use data.\n    console.log(data)\n  })\n  .catch(err =\u003e console.log(err))\n```\n\n#### GET /users\n\n```json\n{\n  \"error\": {\n    \"message\": \"There was an issue connecting to the database.\",\n    \"code\": \"DATABASE_CONNECTION_FAILED\"\n  }\n}\n```\n\n#### POST /users\n\n```json\n{\n  \"error\": {\n    \"message\": \"Some of the inputs you entered are incorrect.\",\n    \"code\": \"CREATE_USER_VALIDATION_FAILED\",\n    \"validationErrors\": {\n      \"email\": \"This email has already been used\",\n      \"password\": \"The password must be at least 8 characters\"\n    }\n  }\n}\n```\n\n---\n\nThe Jres specification was created by [Blake Wilson](https://github.com/blakewilson). The specification and this website are [open source](https://github.com/blakewilson/jres), and are released under the [MIT license](https://github.com/blakewilson/jres/blob/master/LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakewilson%2Fjres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblakewilson%2Fjres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakewilson%2Fjres/lists"}