{"id":21981647,"url":"https://github.com/cronokirby/serve-csv","last_synced_at":"2025-06-17T06:07:27.464Z","repository":{"id":81581543,"uuid":"189468632","full_name":"cronokirby/serve-csv","owner":"cronokirby","description":"Create a web API from static csv files","archived":false,"fork":false,"pushed_at":"2019-06-01T20:11:58.000Z","size":18,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-30T05:06:30.996Z","etag":null,"topics":["api","csv","golang","json-api","web"],"latest_commit_sha":null,"homepage":null,"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/cronokirby.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}},"created_at":"2019-05-30T19:11:12.000Z","updated_at":"2023-03-16T04:44:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"f4a3caf4-f80c-4860-b4c6-b889006f77a3","html_url":"https://github.com/cronokirby/serve-csv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cronokirby/serve-csv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cronokirby%2Fserve-csv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cronokirby%2Fserve-csv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cronokirby%2Fserve-csv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cronokirby%2Fserve-csv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cronokirby","download_url":"https://codeload.github.com/cronokirby/serve-csv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cronokirby%2Fserve-csv/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260301993,"owners_count":22988722,"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","csv","golang","json-api","web"],"created_at":"2024-11-29T17:18:54.667Z","updated_at":"2025-06-17T06:07:27.441Z","avatar_url":"https://github.com/cronokirby.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# serve-csv\n`serve-csv` is a small CLI program that allows you to start serving a folder\nof CSV files as a JSON API. Each CSV file is required to come with a JSON file specifying\nhow each column maps to a JSON field.\n\n## Example\nThe example data for this section can be found in the `example-data` folder.\n\nTo be able to serve CSV, we need to have some data we want to serve.\nLet's put the following rows into `example-data/people.csv`:\n```\n\"John\",\"Smith\"\n\"Alexa\",\"Miller\"\n\"Anthony\",\"Hopkins\"\n\"Maxi\",\"Toshins\"\n\"Clarice\",\"Cromwell\"\n```\n\nBefore we can serve this file, we need to have a corresponding `example-data/people.json`\nfile, which tells us how to convert each column into a JSON field.\nThis file looks like this:\n```json\n{\"fields\": [\"firstName\", \"lastName\"], \"types\": [\"string\", \"string\"]}\n```\n\nThe `fields` field contains a list of names, one for each column, telling the program\nwhat name to use as a field for that column. The `types` field is an array of the same length\nas `fields`, one element per column again, where each element specifies what type the field in that\nrow should be interpreted as. The available types atm are \"string\" and \"int\". \"string\" will leave the\ncolumn as a JSON string, and \"int\" as a number.\n\nGiven this JSON schema, the first row of our CSV will go from:\n```\n\"John\",\"Smith\"\n```\nto\n```json\n{\"firstName\": \"John\", \"lastName\": \"Smith\"}\n```\n\nTo serve this folder as an API, we can do:\n```\nserve-csv example-data\n```\n\nBefore starting the API, this will first make sure that each CSV file in the folder has a corresponding\nJSON schema. The JSON schemas will also be checked for consistency with the format we aligned above.\nFinally, the CSV file will be scanned to check for consistency with the schema as well.\n\nThe JSON data for our example should be accessible after the previous command at: `http://localhost:1234/people`.\n\nFor each CSV file, the program creates an endpoint to fetch all of the rows, as well as a parameterised endpoint for a single row.\nFor example, our `people.csv` file maps to a `/people` endpoint, as well as a `/people/i` endpoint for the ith row (starting at 0).\nIf we had a `cats.csv` file, this would get its own `/cats` and `/cats/i` endpoints as well, etc.\n\n## Usage\n```\nusage: serve-csv [\u003cflags\u003e] \u003cdir\u003e\n\nFlags:\n      --help         Show context-sensitive help (also try --help-long and --help-man).\n  -p, --port=\"1234\"  The port to listen on\n\nArgs:\n  \u003cdir\u003e  The directory to serve\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcronokirby%2Fserve-csv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcronokirby%2Fserve-csv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcronokirby%2Fserve-csv/lists"}