{"id":20607281,"url":"https://github.com/hongquan/curlipie","last_synced_at":"2025-04-15T03:55:22.183Z","repository":{"id":40290182,"uuid":"235409381","full_name":"hongquan/CurliPie","owner":"hongquan","description":"Convert cURL command to HTTPie","archived":false,"fork":false,"pushed_at":"2025-02-09T12:18:02.000Z","size":1328,"stargazers_count":70,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T03:55:16.581Z","etag":null,"topics":["alpinejs","api","conversion","curl","fastapi","http","httpie","made-in-vietnam","tailwindcss"],"latest_commit_sha":null,"homepage":"https://curlipie.open-api.vn/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hongquan.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-01-21T18:12:08.000Z","updated_at":"2025-02-09T12:18:04.000Z","dependencies_parsed_at":"2023-01-22T11:45:10.566Z","dependency_job_id":"20af4136-20c5-45e6-b39d-890381cbbe9f","html_url":"https://github.com/hongquan/CurliPie","commit_stats":{"total_commits":93,"total_committers":2,"mean_commits":46.5,"dds":"0.16129032258064513","last_synced_commit":"4070cf1f4e5b88c41fdc24e17bd0050b6aa04bcf"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongquan%2FCurliPie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongquan%2FCurliPie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongquan%2FCurliPie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongquan%2FCurliPie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hongquan","download_url":"https://codeload.github.com/hongquan/CurliPie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249003953,"owners_count":21196794,"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":["alpinejs","api","conversion","curl","fastapi","http","httpie","made-in-vietnam","tailwindcss"],"created_at":"2024-11-16T10:06:14.732Z","updated_at":"2025-04-15T03:55:22.165Z","avatar_url":"https://github.com/hongquan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"========\nCurliPie\n========\n\n.. image:: https://madewithlove.vercel.app/vn?heart=true\u0026colorA=%23ffcd00\u0026colorB=%23da251d\n.. image:: https://badgen.net/pypi/v/curlipie\n   :target: https://pypi.org/project/curlipie\n\nPython library to convert `cURL`_ command to `HTTPie`_.\n\nIt will convert\n\n.. code-block:: sh\n\n    curl -d name=admin -d shoesize=12 -d color=green\u0026food=wet http://quan.hoabinh.vn\n\nto\n\n.. code-block:: sh\n\n    http -f http://quan.hoabinh.vn name=admin shoesize=12 color=green food=wet\n\n\nMotivation\n----------\n\nThis library was born when I joined a project with a team of non-Linux, non-Python developers. Because the project didn't have proper documentation, the other team often shared API usage example to me in form of cURL command, generated from their daily-used Postman. Those cURL commands are usually ugly, like this:\n\n\n.. code-block:: sh\n\n    curl --location --request POST 'http://app-staging.dev/api' \\\n    --header 'Content-Type: application/json' \\\n    --data-raw '{\n        \"userId\": \"abc-xyz\",\n        \"planAmount\": 50000,\n        \"isPromotion\": false,\n        \"createdAt\": \"2019-12-13 10:00:00\"\n    }'\n\nI am more comfortable with HTTPie (shorter syntax, has highlighting and is a Python application), so I often converted it to HTTPie:\n\n.. code-block:: sh\n\n    http -F app-staging.dev/api userId=abc-xyz planAmount:=50000 isPromotion:=false createdAt='2019-12-13 10:00:00'\n\nThough Postman can generate HTTPie, it does result in even uglier command:\n\n.. code-block:: sh\n\n    printf '{\n        \"userId\": \"abc-xyz\",\n        \"planAmount\": 50000,\n        \"isPromotion\": false,\n        \"createdAt\": \"2019-12-13 10:00:00\"\n    }'| http  --follow --timeout 3600 POST app-staging.dev/api \\\n    Content-Type:'application/json'\n\nInitially, I had to do conversion manually and quickly got tired from it. I tried to find a conversion tool but failed. There is an online tool `curl2httpie.online`_, but it failed with above example. So I decide to write my own tool.\n\nI don't bother to help fix the online tool above, because it is written in Go. The rich ecosystem of Python, with these built-in libraries, enable me to finish the job fast:\n\n- |shlex|_: Help parse the command line in form of shell language, handle the string escaping, quoting for me.\n- |argparse|_: Help parse cURL options and arguments. Note that, cURL arguments syntax follow GNU style, which is common in Linux (and Python) world but not popular in Go world (see `this tutorial \u003cgo_tutorial_\u003e`_), so it feels more natural with Python.\n\n\nUsage\n-----\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from curlipie import curl_to_httpie\n\n    \u003e\u003e\u003e curl = \"\"\"curl -XPUT elastic.dev/movies/_doc/1 -d '{\"director\": \"Burton, Tim\", \"year\": 1996, \"title\": \"Mars Attacks!\"}' -H 'Content-Type: application/json'\"\"\"\n\n    \u003e\u003e\u003e curl_to_httpie(curl)\n    ConversionResult(httpie=\"http PUT elastic.dev/movies/_doc/1 director='Burton, Tim' year:=1996 title='Mars Attacks!'\", errors=[])\n\n    \u003e\u003e\u003e result = curl_to_httpie(curl)\n\n    \u003e\u003e\u003e result.httpie\n    \"http PUT elastic.dev/movies/_doc/1 director='Burton, Tim' year:=1996 title='Mars Attacks!'\"\n\n\nOnline tool\n-----------\n\nCurliPie is not very usable if it stays in library form, so I made an online tool for you to use it quickly:\n\nhttps://curlipie.open-api.vn\n\nThe site also provide HTTP API for you to develop a client for it.\n\n\nDevelopment\n-----------\n\nThis repo contains three components:\n\n- Python library ``curlipie``. This is the one `published`_ to PyPI.\n\n- An API server built with `FastAPI`_, playing role of backend for `curlipie.open-api.vn`_.\n\n- A minimal frontend app built with `AlpineJS`_ and `UnoCSS`_ (with `TailwindCSS`_ style).\n\n- Python dependencies are managed with `Poetry`_.\n\nTo try running on localhost:\n\n- Run backend with:\n\n  .. code-block:: sh\n\n    uvicorn api.main:app\n\n- The front-end are just static files, served by backend also, so you can access it via http://localhost:8000/. The CSS is generated depending on which CSS classes are used. To generate CSS file, install `Bun`_, then run the command:\n\n  .. code-block:: sh\n\n    ./tools/generate-css.sh\n\n\nUnit test:\n\n    .. code-block:: sh\n\n        pytest\n\n\nCredit\n------\n\nBrought to you by `Nguyễn Hồng Quân \u003cauthor_\u003e`_.\n\n\n.. _cURL: https://curl.haxx.se\n.. _HTTPie: https://httpie.org\n.. _curl2httpie.online: https://curl2httpie.online/\n.. |shlex| replace:: ``shlex``\n.. _shlex: https://docs.python.org/3/library/shlex.html\n.. |argparse| replace:: ``argparse``\n.. _argparse: https://docs.python.org/3/library/argparse.html\n.. _go_tutorial: https://gobyexample.com/command-line-flags\n.. _published: https://pypi.org/project/curlipie/\n.. _fastapi: https://github.com/tiangolo/fastapi\n.. _curlipie.open-api.vn: https://curlipie.open-api.vn/\n.. _vuejs: https://vuejs.org/\n.. _alpinejs: https://github.com/alpinejs/alpine\n.. _unocss: https://unocss.dev/\n.. _tailwindcss: https://tailwindcss.com\n.. _bun: https://bun.css\n.. _poetry: https://python-poetry.org/\n.. _author: https://quan.hoabinh.vn\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhongquan%2Fcurlipie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhongquan%2Fcurlipie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhongquan%2Fcurlipie/lists"}