{"id":51163543,"url":"https://github.com/dorylab/d1-rest","last_synced_at":"2026-06-26T16:31:08.540Z","repository":{"id":365190708,"uuid":"1270968996","full_name":"dorylab/d1-rest","owner":"dorylab","description":null,"archived":false,"fork":false,"pushed_at":"2026-06-16T08:00:08.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-16T10:04:39.803Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/dorylab.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-16T07:59:52.000Z","updated_at":"2026-06-16T08:00:19.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/dorylab/d1-rest","commit_stats":null,"previous_names":["dorylab/d1-rest"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/dorylab/d1-rest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorylab%2Fd1-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorylab%2Fd1-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorylab%2Fd1-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorylab%2Fd1-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dorylab","download_url":"https://codeload.github.com/dorylab/d1-rest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorylab%2Fd1-rest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34825610,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-26T02:00:06.560Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2026-06-26T16:31:05.246Z","updated_at":"2026-06-26T16:31:08.534Z","avatar_url":"https://github.com/dorylab.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# d1-secret-rest\nFetch results or execute queries against a D1 CRUD REST API\n\n## Performance\nThis REST API implementation offers significantly faster performance compared to the official D1 API:\n\n| API | Avg. Speed | Avg. Response Time |\n|-----|------------|-------------------|\n| d1-secret-rest | 1,729 bytes/sec | 0.22 seconds |\n| Official D1 API | 574 bytes/sec | 0.79 seconds |\n\n\u003e Based on benchmark testing with identical queries. d1-secret-rest performs ~3x faster on average.\n\n## Quick Start\n```bash\n# Example: Get users with filtering and pagination\ncurl --location 'https://d1-rest.\u003cYOUR-IDENTIFIER\u003e.workers.dev/rest/users?limit=2\u0026age=25' \\\n--header 'Authorization: Bearer \u003cYOUR-SECRET-VALUE\u003e'\n\n# Example: Execute raw SQL query\ncurl --location 'https://d1-rest.\u003cYOUR-IDENTIFIER\u003e.workers.dev/query' \\\n--header 'Authorization: Bearer \u003cYOUR-SECRET-VALUE\u003e' \\\n--header 'Content-Type: application/json' \\\n--data '{\n    \"query\": \"SELECT * FROM users WHERE age \u003e ? LIMIT ?;\",\n    \"params\": [21, 2]\n}'\n```\n\n## Authentication\nAll endpoints require authentication using a Bearer token:\n```bash\n--header 'Authorization: Bearer \u003cYOUR-SECRET-VALUE\u003e'\n```\n\n## REST API Endpoints\n\n### List Records\n```bash\n# Basic listing\nGET /rest/{table}\n\n# With filtering\nGET /rest/{table}?column_name=value\nGET /rest/{table}?age=25\u0026status=active\n\n# With sorting\nGET /rest/{table}?sort_by=column_name\u0026order=asc\nGET /rest/{table}?sort_by=name\u0026order=desc\n\n# With pagination\nGET /rest/{table}?limit=10\u0026offset=20\n\n# Combined example\nGET /rest/{table}?age=25\u0026sort_by=name\u0026order=desc\u0026limit=10\u0026offset=20\n```\n\n### Get Single Record\n```bash\nGET /rest/{table}/{id}\n```\n\n### Create Record\n```bash\nPOST /rest/{table}\nContent-Type: application/json\n\n{\n    \"column1\": \"value1\",\n    \"column2\": \"value2\"\n}\n```\n\nExample:\n```bash\nPOST /rest/users\nContent-Type: application/json\n\n{\n    \"name\": \"John Doe\",\n    \"age\": 30,\n    \"email\": \"john@example.com\"\n}\n```\n\n### Update Record\n```bash\nPATCH /rest/{table}/{id}\nContent-Type: application/json\n\n{\n    \"column1\": \"new_value\"\n}\n```\n\nExample:\n```bash\nPATCH /rest/users/123\nContent-Type: application/json\n\n{\n    \"age\": 31,\n    \"email\": \"john.doe@example.com\"\n}\n```\n\n### Delete Record\n```bash\nDELETE /rest/{table}/{id}\n```\n\n## Raw SQL Queries\nFor more complex queries, you can use the raw SQL endpoint:\n\n```bash\nPOST /query\nContent-Type: application/json\n\n{\n    \"query\": \"SELECT * FROM users WHERE age \u003e ? AND status = ? LIMIT ?;\",\n    \"params\": [21, \"active\", 10]\n}\n```\n\n## Query Parameters\n\n| Parameter | Description | Example |\n|-----------|-------------|---------|\n| `sort_by` | Column to sort by | `sort_by=name` |\n| `order` | Sort order (asc/desc) | `order=desc` |\n| `limit` | Maximum number of records to return | `limit=10` |\n| `offset` | Number of records to skip | `offset=20` |\n| Any column name | Filter by column value | `age=25` |\n\n## Response Format\n\n### Successful Response\n```json\n{\n    \"success\": true,\n    \"meta\": {\n        \"served_by\": \"v3-prod\",\n        \"served_by_region\": \"ENAM\",\n        \"served_by_primary\": true,\n        \"timings\": {\n            \"sql_duration_ms\": 0.1746\n        },\n        \"duration\": 0.1746,\n        \"changes\": 0,\n        \"last_row_id\": 0,\n        \"changed_db\": false,\n        \"size_after\": 28672,\n        \"rows_read\": 2,\n        \"rows_written\": 0\n    },\n    \"results\": [\n        {\n            \"user_id\": 1,\n            \"name\": \"Alice\",\n            \"email\": \"alice@example.com\"\n        },\n        {\n            \"user_id\": 2,\n            \"name\": \"Bob\",\n            \"email\": \"bob@example.com\"\n        }\n    ]\n}\n```\n\n### Error Response\n```json\n{\n    \"success\": false,\n    \"error\": \"Error message here\"\n}\n```\n\nThe response includes:\n- `success`: Boolean indicating if the request was successful\n- `meta`: Execution metadata including timing and database statistics\n- `results`: Array of returned records (for GET requests)\n\n## Security Notes\n- All column names and table names are sanitized to prevent SQL injection\n- Only alphanumeric characters and underscores are allowed in identifiers\n- Authentication is required for all endpoints","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdorylab%2Fd1-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdorylab%2Fd1-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdorylab%2Fd1-rest/lists"}