{ "info": { "author": "Opendata Team", "author_email": "opendatateam@data.gouv.fr", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython" ], "description": "# csvapi\n\n\"Instantly\" publish an API for a CSV hosted anywhere on the internet. Also supports Excel files.\n\nThis tool is used by [data.gouv.fr](https://www.data.gouv.fr) to show a preview of hosted CSV and XLS files.\n\n## Installation\n\nRequires Python 3.7+ and a Unix OS with the `file` command available.\n\n```shell\npython3 -m venv pyenv && . pyenv/bin/activate\npip install csvapi\n```\n\nFor development:\n\n```shell\npip install -r requirements/develop.pip\npip install -e .\n```\n\n## Quickstart\n\n```shell\ncsvapi serve -h 0.0.0.0 -p 8000\n```\n\n## Command line options\n\n```shell\n$ csvapi serve --help\nUsage: csvapi serve [OPTIONS]\n\nOptions:\n --ssl-key TEXT Path to SSL key\n --ssl-cert TEXT Path to SSL certificate\n -w, --max-workers INTEGER Max number of ThreadPoolExecutor workers\n --cache / --no-cache Do not parse CSV again if DB already exists\n --reload Automatically reload if code change detected\n --debug Enable debug mode - useful for development\n -p, --port INTEGER port for server, defaults to 8001\n -h, --host TEXT host for server, defaults to 127.0.0.1\n --dbs DIRECTORY Where to store sqlite DBs\n --help Show this message and exit.\n```\n\n## Deploy\n\nWith SSL, using [Hypercorn](https://pgjones.gitlab.io/hypercorn/):\n\n```shell\nhypercorn csvapi.webservice:app -b 0.0.0.0:443 --keyfile key.pem --ca-certs cert.pem\n```\n\nSee [the documentation](https://pgjones.gitlab.io/hypercorn/usage.html) for more options.\n\nYou can use the environment variable `CSVAPI_CONFIG_FILE` to point to a custom configuration file.\n\n## API usage\n\n### Conversion\n\n`/apify?url=http://somewhere.com/a/file.csv`\n\nThis converts a CSV to an SQLite database (w/ `agate`) and returns the following response:\n\n```json\n{\"ok\": true, \"endpoint\": \"http://localhost:8001/api/cde857960e8dc24c9cbcced673b496bb\"}\n```\n\n### Parameters\n\nSome parameters can be used in the query string.\n\n#### `encoding`\n\n**default**: _automatic detection_\n\nYou can force an encoding (e.g. `utf-8`) using this parameter, instead of relying on the automatic detection.\n\n\n### Data API\n\nThis is the `endpoint` attribute of the previous response.\n\n`/api/`\n\nThis queries a previously converted API file and returns the first 100 rows like this:\n\n```json\n {\n \"ok\": true,\n \"rows\": [[], []],\n \"columns\": [],\n \"query_ms\": 1\n }\n```\n\n### Parameters\n\nSome parameters can be used in the query string.\n\n#### `_size`\n\n**default**: `100`\n\nThis will limit the query to a certain number of rows. For instance to get only 250 rows:\n\n`/api/?_size=250`\n\n#### `_sort` and `_sort_desc`\n\nUse those to sort by a column. `sort` will sort by ascending order, `sort_desc` by descending order.\n\n`/api/?_sort=`\n\n#### `_offset`\n\nUse this to add on offset. Combined with `_size` it allows pagination.\n\n`/api/?_size=1&_offset=1`\n\n#### `_shape`\n\n**default**: `lists`\n\nThe `_shape` argument is used to specify the format output of the json. It can take the value `objects` to get an array of objects instead of an array of arrays:\n\n`/api/?_shape=objects`\n\nFor instance, instead of returning:\n\n```json\n{\n \"ok\": true,\n \"query_ms\": 0.4799365997,\n \"rows\": [\n [1, \"Justice\", \"0101\", 57663310],\n [2, \"Justice\", \"0101\", 2255129],\n [3, \"Justice\", \"0101\", 36290]\n ],\n \"columns\": [\"rowid\", \"Mission\", \"Programme\", \"Consommation de CP\"]\n}\n```\n\nIt will return:\n\n```json\n{\n \"ok\": true,\n \"query_ms\": 2.681016922,\n \"rows\": [\n {\n \"rowid\": 1,\n \"Mission\": \"Justice\",\n \"Programme\": \"0101\",\n \"Consommation de CP\": 57663310\n },\n {\n \"rowid\": 2,\n \"Mission\": \"Justice\",\n \"Programme\": \"0101\",\n \"Consommation de CP\": 2255129\n },\n {\n \"rowid\": 3,\n \"Mission\": \"Justice\",\n \"Programme\": \"0101\",\n \"Consommation de CP\": 36290\n }],\n \"columns\": [\"rowid\", \"Mission\", \"Programme\", \"Consommation de CP\"]\n}\n```\n\n#### `_rowid`\n\n**default**: `show`\n\nThe `_rowid` argument is used to display or hide rowids in the returned data. Use `_rowid=hide` to hide.\n\n`/api/?_shape=objects&_rowid=hide`\n\n```json\n{\n \"ok\": true,\n \"query_ms\": 2.681016922,\n \"rows\": [\n {\n \"Mission\": \"Justice\",\n \"Programme\": \"0101\",\n \"Consommation de CP\": 57663310\n },\n {\n \"Mission\": \"Justice\",\n \"Programme\": \"0101\",\n \"Consommation de CP\": 2255129\n },\n {\n \"Mission\": \"Justice\",\n \"Programme\": \"0101\",\n \"Consommation de CP\": 36290\n }],\n \"columns\": [\"Mission\", \"Programme\", \"Consommation de CP\"]\n}\n```\n\n#### `_total`\n\n**default**: `show`\n\nThe `_total` argument is used to display or hide the total number of rows (independent of pagination) in the returned data. Use `_total=hide` to hide.\n\n```json\n{\n \"ok\": true,\n \"query_ms\": 2.681016922,\n \"rows\": [\n {\n \"Mission\": \"Justice\",\n \"Programme\": \"0101\",\n \"Consommation de CP\": 57663310\n },\n {\n \"Mission\": \"Justice\",\n \"Programme\": \"0101\",\n \"Consommation de CP\": 2255129\n },\n {\n \"Mission\": \"Justice\",\n \"Programme\": \"0101\",\n \"Consommation de CP\": 36290\n }],\n \"columns\": [\"Mission\", \"Programme\", \"Consommation de CP\"],\n \"total\": 3\n}\n```\n\n## Production deployment\n\nSome example [Ansible 2](https://www.ansible.com) roles are [available here](/ansible).\n\n## Credits\n\nInspired by the excellent [Datasette](https://github.com/simonw/datasette).\n\n# Changelog\n\n## 0.1.0 (2019-09-06)\n\n- Upgrade to Quart-0.9.1 :warning: requires python-3.7 [#21](https://github.com/opendatateam/csvapi/pull/21)\n- Parse hours, SIREN and SIRET as text [#42](https://github.com/opendatateam/csvapi/pull/42)\n\n## 0.0.9 (2019-01-18)\n\n- Upgrade to Quart-0.6.6 and hypercorn-0.4.6 [#16](https://github.com/opendatateam/csvapi/pull/16)\n\n## 0.0.8 (2018-10-04)\n\n- Try to parse CSV w/o sniffing (excel dialect) after sniffing if it fails\n\n## 0.0.7 (2018-09-17)\n\n- `MAX_FILE_SIZE` config variable [#13](https://github.com/opendatateam/csvapi/pull/13)\n- Add filter by referrer feature (REFERRERS_FILTER) [#14](https://github.com/opendatateam/csvapi/pull/14)\n\n## 0.0.6 (2018-09-10)\n\n- Compute the total number of rows in a table [#12](https://github.com/opendatateam/csvapi/pull/12)\n\n## 0.0.5 (2018-09-10)\n\n- Make CSV sniff limit a config variable and raise the default value [#11](https://github.com/opendatateam/csvapi/pull/11)\n- Properly handle not found (404) errors\n\n## 0.0.4 (2018-09-04)\n\n- FORCE_SSL config variable\n\n## 0.0.3 (2018-08-31)\n\n- Sentry support via SENTRY_DSN config variable\n\n## 0.0.2 (2018-08-30)\n\n- CSVAPI_CONFIG_FILE env var support\n\n## 0.0.1 (2018-08-30)\n\n- Initial version\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/opendatateam/csvapi", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "csvapi", "package_url": "https://pypi.org/project/csvapi/", "platform": "", "project_url": "https://pypi.org/project/csvapi/", "project_urls": { "Homepage": "https://github.com/opendatateam/csvapi" }, "release_url": "https://pypi.org/project/csvapi/0.1.0/", "requires_dist": [ "click-default-group (==1.2.1)", "click (==7.0)", "requests (==2.22.0)", "agate (==1.6.1)", "agate-sql (==0.5.4)", "validators (==0.13.0)", "agate-excel (==0.2.3)", "Quart (==0.9.1)", "raven (==6.10.0)", "cchardet (==2.1.4)", "python-stdnum (==1.11)", "requests-mock (==1.5.2) ; extra == 'test'", "pytest (==3.7.4) ; extra == 'test'", "aiohttp (==3.5.4) ; extra == 'test'", "pytest-asyncio (==0.8.0) ; extra == 'test'" ], "requires_python": ">=3.6.1", "summary": "An instant JSON API for your CSV", "version": "0.1.0" }, "last_serial": 5791921, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "5cfd0c0e1285ba395e01f06e9aefa944", "sha256": "466277cb8b24b117f2e3c2dc0db859794c14bdb59fdd7581462e902871438a28" }, "downloads": -1, "filename": "csvapi-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5cfd0c0e1285ba395e01f06e9aefa944", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9658, "upload_time": "2018-08-30T12:17:03", "url": "https://files.pythonhosted.org/packages/9c/d2/b7097d1ad5651e0d52c709d51779a9e56afd200358e91b6bd4707901d3e5/csvapi-0.0.1-py3-none-any.whl" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "845462f8d041dd8444269661bcce1e62", "sha256": "f89105ef2ae35abfddaaa7b6fab59f43cd027e973725dee5db9c474c59595f73" }, "downloads": -1, "filename": "csvapi-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "845462f8d041dd8444269661bcce1e62", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9785, "upload_time": "2018-08-30T15:56:12", "url": "https://files.pythonhosted.org/packages/a5/98/0c8937f950027c2f3f2af0f0b8dcd6d0a3767decc9015e56e7cbb78277c1/csvapi-0.0.2-py3-none-any.whl" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "e6301497b87ede82d3993d6bc4adad75", "sha256": "672d964a3e59289621dd174f8450954d4fdacdc7030c62dac06bdc62ff90fe3c" }, "downloads": -1, "filename": "csvapi-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "e6301497b87ede82d3993d6bc4adad75", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.1", "size": 10058, "upload_time": "2018-08-31T11:07:23", "url": "https://files.pythonhosted.org/packages/43/9c/d38638fb42ac801b246be53606741cbeb6e1f61374d500260bc34a5be278/csvapi-0.0.3-py3-none-any.whl" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "9972c9a99727cc6a880a77ac1d147961", "sha256": "4e9a9af3f5e1fe60f10f2a2c1a1b82ab7f33778bbcea1c00e56eacb31114cad3" }, "downloads": -1, "filename": "csvapi-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "9972c9a99727cc6a880a77ac1d147961", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.1", "size": 10109, "upload_time": "2018-09-04T16:23:39", "url": "https://files.pythonhosted.org/packages/7b/5c/b77c08847f594e45ec7582f179592347ca9ebfdc781ef64df2d24fbcb8a2/csvapi-0.0.4-py3-none-any.whl" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "71db593054e3a0d3c4fbe3a1ae326e1b", "sha256": "e65f6a6b210335ece94f5c97e0f103acf1e5bfae0b0c453e51e25d4fa44b045b" }, "downloads": -1, "filename": "csvapi-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "71db593054e3a0d3c4fbe3a1ae326e1b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.1", "size": 10299, "upload_time": "2018-09-10T08:58:15", "url": "https://files.pythonhosted.org/packages/b6/c8/cdd53c9cf8f2c45db44690f842c6ef0de38ff57b878e651152d1834913dd/csvapi-0.0.5-py3-none-any.whl" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "32373e684b0d4e6a675390a27202b4a5", "sha256": "7f0cbacf4d6963e4a494c87f82d8fe396782bba453738f245044e1d7d2367b17" }, "downloads": -1, "filename": "csvapi-0.0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "32373e684b0d4e6a675390a27202b4a5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.1", "size": 10470, "upload_time": "2018-09-10T12:58:07", "url": "https://files.pythonhosted.org/packages/17/4a/6a0f716abd49670c7bab5a6ea0938791bb39f43f5429e7b729cbc8fae250/csvapi-0.0.6-py3-none-any.whl" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "d32fbcce018db7aefa5fc510eaca898e", "sha256": "7a20f91a0fb193855a17dc0bcdc6709cec45bf4f8b3951a7d5604546557fcaf6" }, "downloads": -1, "filename": "csvapi-0.0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "d32fbcce018db7aefa5fc510eaca898e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.1", "size": 11081, "upload_time": "2018-09-17T12:55:00", "url": "https://files.pythonhosted.org/packages/e3/8e/82e7bcbea9dcc6e020ce7a3158e40e587e1573c7c33fca13b055ea88e973/csvapi-0.0.7-py3-none-any.whl" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "d1cd9b0f00c556f55dc48a1fda887a5b", "sha256": "f94d8407167f8f62aa1b8cdaf637c493093c3ff3d09154886f942e5e2c008704" }, "downloads": -1, "filename": "csvapi-0.0.8-py3-none-any.whl", "has_sig": false, "md5_digest": "d1cd9b0f00c556f55dc48a1fda887a5b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.1", "size": 11180, "upload_time": "2018-10-04T08:01:34", "url": "https://files.pythonhosted.org/packages/40/7d/8b0c41441dafb561ce572bf784880dea12268f261daa6bcc83ea9c9430d6/csvapi-0.0.8-py3-none-any.whl" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "e79781eea672b7105848df06813b87a1", "sha256": "18155936cfaea58992c980a5a684290d50ac852759c93c660d7a2b6094aaa6c1" }, "downloads": -1, "filename": "csvapi-0.0.9-py3-none-any.whl", "has_sig": false, "md5_digest": "e79781eea672b7105848df06813b87a1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.1", "size": 12017, "upload_time": "2019-01-18T09:24:49", "url": "https://files.pythonhosted.org/packages/ab/7e/51ec1a765b4c930aae7430fee3214f90d7eacf3178246495acc69799d783/csvapi-0.0.9-py3-none-any.whl" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "3272ca92fd5f8ae57f542649d6b101b9", "sha256": "811fb585f51d8eb326b602c8490426f19526ff05551da06288066ea0712f8e6e" }, "downloads": -1, "filename": "csvapi-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "3272ca92fd5f8ae57f542649d6b101b9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.1", "size": 13229, "upload_time": "2019-09-06T12:15:26", "url": "https://files.pythonhosted.org/packages/ae/41/6fe9b0047abee232977c629dbcc1fe43ac5ebdb54ec300f5c5329d135721/csvapi-0.1.0-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3272ca92fd5f8ae57f542649d6b101b9", "sha256": "811fb585f51d8eb326b602c8490426f19526ff05551da06288066ea0712f8e6e" }, "downloads": -1, "filename": "csvapi-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "3272ca92fd5f8ae57f542649d6b101b9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.1", "size": 13229, "upload_time": "2019-09-06T12:15:26", "url": "https://files.pythonhosted.org/packages/ae/41/6fe9b0047abee232977c629dbcc1fe43ac5ebdb54ec300f5c5329d135721/csvapi-0.1.0-py3-none-any.whl" } ] }