{"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1313125870", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1313125870, "node_id": "IC_kwDOBm6k_c5ORLXu", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-14T05:42:50Z", "updated_at": "2022-11-14T05:42:50Z", "author_association": "OWNER", "body": "Demo: https://latest-1-0-dev.datasette.io/-/api#path=%2Ffixtures%2Ffacetable%2F-%2Fdrop&json=%7B%22confirm%22%3A+true%7D&method=POST", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1313097057", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1313097057, "node_id": "IC_kwDOBm6k_c5OREVh", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-14T04:59:28Z", "updated_at": "2022-11-14T04:59:28Z", "author_association": "OWNER", "body": "In playing with the API explorer just now I realized it's way too easy to accidentally drop a table using it.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1313072900", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1313072900, "node_id": "IC_kwDOBm6k_c5OQ-cE", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-14T04:15:50Z", "updated_at": "2022-11-14T04:15:50Z", "author_association": "OWNER", "body": "For the example links - I'm going to have these at the bottom of the page so you don't have to scroll past them.\r\n\r\nIdeally these would take the user's permissions into account. This could make the page expensive to load, but I'm going to risk it for the moment.\r\n\r\nSomething like this then:\r\n\r\n> - data\r\n> - /data/-/create - create table\r\n> - /data/table1/-/insert - insert into table1\r\n> - /data/table1/-/drop - drop table1\r\n\r\nI won't bother with per-row demo links (for update and delete) because there could be thousands of them for each table.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1313062699", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1313062699, "node_id": "IC_kwDOBm6k_c5OQ78r", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-14T04:03:29Z", "updated_at": "2022-11-14T04:12:41Z", "author_association": "OWNER", "body": "Two things left before I close this issue:\r\n\r\n- [x] I want to preserve the state of the forms in the URL - probably after a `#`\r\n- [ ] Instead of hard-coding the current examples, I want to provide a list of links which populate the forms", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1312822353", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1312822353, "node_id": "IC_kwDOBm6k_c5OQBRR", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-13T21:07:40Z", "updated_at": "2022-11-13T21:07:40Z", "author_association": "OWNER", "body": "I'm going to need extra code to toggle POST closed when GET opens and vice-versa.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1312821031", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1312821031, "node_id": "IC_kwDOBm6k_c5OQA8n", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-13T21:02:06Z", "updated_at": "2022-11-13T21:03:11Z", "author_association": "OWNER", "body": "Actually no, I'm going to add a class of `details-menu` to the other details elements that SHOULD be closed. That way custom templates using `
` won't close in a surprising way.", "reactions": "{\"total_count\": 1, \"+1\": 1, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1312816451", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1312816451, "node_id": "IC_kwDOBm6k_c5OP_1D", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-13T20:39:26Z", "updated_at": "2022-11-13T20:39:34Z", "author_association": "OWNER", "body": "I'm going to add a special `no-auto-close` class to these and teach that code not to close them.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1312816292", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1312816292, "node_id": "IC_kwDOBm6k_c5OP_yk", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-13T20:38:42Z", "updated_at": "2022-11-13T20:38:42Z", "author_association": "OWNER", "body": "The current API explorer uses details/summary elements for the GET and POST dialogs.\r\n\r\nI only want one of these to be open at a time, to reflect that you can make either a GET or a POST.\r\n\r\nI just noticed that clicking anywhere else on the page closes both elements, which isn't what I want to happen. Turns out that's because of this code I added as part of Datasette's menu implementation!\r\n\r\nhttps://github.com/simonw/datasette/blob/9f54f00a50a4d950cfd69a0ff3526ae82c858826/datasette/templates/_close_open_menus.html#L2-L15", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1309650806", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1309650806, "node_id": "IC_kwDOBm6k_c5OD692", "user": {"value": 3556, "label": "davidbgk"}, "created_at": "2022-11-10T01:38:58Z", "updated_at": "2022-11-10T01:38:58Z", "author_association": "CONTRIBUTOR", "body": "> Realized the API explorer doesn't need the API key piece at all - it can work with standard cookie-based auth.\r\n> \r\n> This also reflects how most plugins are likely to use this API, where they'll be adding JavaScript that uses `fetch()` to call the write API directly.\r\n\r\nI agree (that's what I did with the previous insert plugin), maybe a complete example using `fetch()` in the documentation would be valuable as a \u201cGetting started with the API\u201d or similar?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1302815105", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1302815105, "node_id": "IC_kwDOBm6k_c5Np2GB", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-04T00:17:23Z", "updated_at": "2022-11-04T00:17:23Z", "author_association": "OWNER", "body": "I'll probably enhance it a bit more though, I want to provide a UI that lists all the tables you can explore and lets you click to pre-fill the forms with them.\r\n\r\nThough at that point what should I do about the other endpoints? Probably list those too. Gets a bit complex, especially with the row-level update and delete endpoints.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1302814693", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1302814693, "node_id": "IC_kwDOBm6k_c5Np1_l", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-04T00:16:36Z", "updated_at": "2022-11-04T00:16:36Z", "author_association": "OWNER", "body": "I can close this issue once I fix it so it no longer hard-codes a potentially invalid example endpoint:\r\n\r\nhttps://github.com/simonw/datasette/blob/bcc781f4c50a8870e3389c4e60acb625c34b0317/datasette/templates/api_explorer.html#L24-L26\r\n\r\nhttps://github.com/simonw/datasette/blob/bcc781f4c50a8870e3389c4e60acb625c34b0317/datasette/templates/api_explorer.html#L34-L35", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1299607082", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1299607082, "node_id": "IC_kwDOBm6k_c5Ndm4q", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-02T05:45:31Z", "updated_at": "2022-11-02T05:45:31Z", "author_association": "OWNER", "body": "I'm going to add a link to the Datasette API docs for the current running version of Datasette, e.g. to https://docs.datasette.io/en/0.63/json_api.html", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1299600257", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1299600257, "node_id": "IC_kwDOBm6k_c5NdlOB", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-02T05:36:40Z", "updated_at": "2022-11-02T05:36:40Z", "author_association": "OWNER", "body": "The API Explorer should definitely link to the `/-/create-token` page for users who have permission though.\r\n\r\nAnd it should probably go in the Datasette application menu?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1299599461", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1299599461, "node_id": "IC_kwDOBm6k_c5NdlBl", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-02T05:35:36Z", "updated_at": "2022-11-02T05:36:15Z", "author_association": "OWNER", "body": "Here's a slightly wild idea: what if there was a button on `/-/api` that you could click to turn on \"API explorer mode\" for the rest of the Datasette interface - which sets a cookie, and that cookie means you then see \"API explorer\" links in all sorts of other relevant places in the Datasette UI (maybe tucked away in cog menus).\r\n\r\nOnly reason I don't want to show these to everyone is that I don't think this is a very user-friendly feature: if you don't know what an API is I don't want to expose you to it unnecessarily.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1299598570", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1299598570, "node_id": "IC_kwDOBm6k_c5Ndkzq", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-02T05:34:28Z", "updated_at": "2022-11-02T05:34:28Z", "author_association": "OWNER", "body": "This is pretty useful now. Two features I still want to add:\r\n\r\n- The ability to link to the API explorer such that the form is pre-filled with material from the URL. Need to guard against clickjacking first though, so no-one can link to it in an invisible iframe and trick the user into hitting POST.\r\n- Some kind of list of endpoints so people can click links to start using the API explorer. A list of every table the user can write to with each of their `/db/table/-/insert` endpoints for example.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1299597066", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1299597066, "node_id": "IC_kwDOBm6k_c5NdkcK", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-02T05:32:22Z", "updated_at": "2022-11-02T05:32:22Z", "author_association": "OWNER", "body": "Demo of the latest API explorer:\r\n\r\n![explorer](https://user-images.githubusercontent.com/9599/199406184-1292df42-25ea-4daf-8b54-ca26170ec1ea.gif)\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1299388341", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1299388341, "node_id": "IC_kwDOBm6k_c5Ncxe1", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-02T00:24:28Z", "updated_at": "2022-11-02T00:25:00Z", "author_association": "OWNER", "body": "I want JSON syntax highlighting.\r\n\r\nhttps://github.com/luyilin/json-format-highlight is an MIT licensed tiny highlighter that looks decent for this.\r\n\r\nhttps://unpkg.com/json-format-highlight@1.0.1/dist/json-format-highlight.js", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1299349741", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1299349741, "node_id": "IC_kwDOBm6k_c5NcoDt", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-01T23:22:55Z", "updated_at": "2022-11-01T23:22:55Z", "author_association": "OWNER", "body": "It's weird that the API explorer only lets you explore POST APIs. It should probably also let you explore GET APIs, or be renamed.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1296339386", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1296339386, "node_id": "IC_kwDOBm6k_c5NRJG6", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-30T20:03:04Z", "updated_at": "2022-10-30T20:03:04Z", "author_association": "OWNER", "body": "I do need to skip CSRF for these API calls. I'm going to start out by doing that using the `skip_csrf()` hook to skip CSRF checks on anything with a `content-type: application/json` request header.\r\n\r\n```python\r\n@hookimpl\r\ndef skip_csrf(scope):\r\n if scope[\"type\"] == \"http\":\r\n headers = scope.get(\"headers\")\r\n if dict(headers).get(b'content-type') == b'application/json':\r\n return True\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1296339205", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1296339205, "node_id": "IC_kwDOBm6k_c5NRJEF", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-30T20:02:05Z", "updated_at": "2022-10-30T20:02:05Z", "author_association": "OWNER", "body": "Realized the API explorer doesn't need the API key piece at all - it can work with standard cookie-based auth.\r\n\r\nThis also reflects how most plugins are likely to use this API, where they'll be adding JavaScript that uses `fetch()` to call the write API directly.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1296131872", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1296131872, "node_id": "IC_kwDOBm6k_c5NQWcg", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-30T06:27:56Z", "updated_at": "2022-10-30T06:27:56Z", "author_association": "OWNER", "body": "Initial prototype API explorer is now live at https://latest-1-0-dev.datasette.io/-/api", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1296130073", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1296130073, "node_id": "IC_kwDOBm6k_c5NQWAZ", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-30T06:20:56Z", "updated_at": "2022-10-30T06:20:56Z", "author_association": "OWNER", "body": "That initial prototype looks like this:\r\n\r\n\"image\"\r\n\r\nIt currently shows the returned JSON from the API in an `alert()`. Next I should make that part of the page instead.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1296126389", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1296126389, "node_id": "IC_kwDOBm6k_c5NQVG1", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-30T06:04:48Z", "updated_at": "2022-10-30T06:04:48Z", "author_association": "OWNER", "body": "This is even more important now I have pushed:\r\n- #1866", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1871#issuecomment-1296114136", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1871", "id": 1296114136, "node_id": "IC_kwDOBm6k_c5NQSHY", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-30T05:15:40Z", "updated_at": "2022-10-30T05:15:40Z", "author_association": "OWNER", "body": "Host it at `/-/api`\r\n\r\nIt's an input box with a path in and a textarea you can put JSON in, plus a submit button to post the request.\r\n\r\nIt lists the API endpoints you can use - click on a link to populate the form field plus a example.\r\n\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1427293909, "label": "API explorer tool"}, "performed_via_github_app": null}