{"id":13805415,"url":"https://github.com/ttytm/vibe","last_synced_at":"2025-04-12T01:50:55.634Z","repository":{"id":173704554,"uuid":"651159537","full_name":"ttytm/vibe","owner":"ttytm","description":"Vibe is a request library for V. It utilizes a libcurl binding to enable fast and reliable requests while providing a higher-level API.","archived":false,"fork":false,"pushed_at":"2024-11-15T23:11:50.000Z","size":159,"stargazers_count":34,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T06:02:11.680Z","etag":null,"topics":["cross-platform","curl","http","libcurl","libcurl-bindings","linux","macos","osx","proxy","requests","v","vlang","vlang-library","windows"],"latest_commit_sha":null,"homepage":"https://ttytm.github.io/vibe/","language":"V","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/ttytm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"ko_fi":"tobealive"}},"created_at":"2023-06-08T16:17:04.000Z","updated_at":"2025-02-11T16:53:57.000Z","dependencies_parsed_at":"2023-11-17T19:37:07.400Z","dependency_job_id":"719512d4-b4fd-4ec9-ac18-3179777ba7f2","html_url":"https://github.com/ttytm/vibe","commit_stats":null,"previous_names":["tobealive/vibe","ttytm/vibe"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fvibe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fvibe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fvibe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttytm%2Fvibe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ttytm","download_url":"https://codeload.github.com/ttytm/vibe/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505871,"owners_count":21115354,"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":["cross-platform","curl","http","libcurl","libcurl-bindings","linux","macos","osx","proxy","requests","v","vlang","vlang-library","windows"],"created_at":"2024-08-04T01:01:00.899Z","updated_at":"2025-04-12T01:50:55.599Z","avatar_url":"https://github.com/ttytm.png","language":"V","readme":"\u003cdiv align=\"center\"\u003e\n\n# [![logo](https://github.com/ttytm/vibe/assets/34311583/b894de5f-cdcd-4002-82ee-29d2c9b4eccd)](https://github.com/ttytm/vibe)\n\n\u003c/div\u003e\n\nVibe is a request library that wraps libcurl to enable fast and reliable requests while providing a\nhigher-level API.\n\n## Installation\n\n- Install via V's cli\n\n  ```sh\n  v install https://github.com/ttytm/vibe\n  ```\n\n- Setup development dependency\n\n  ```sh\n  v ~/.vmodules/vibe/curl/setup.vsh\n  ```\n\n## Usage\n\n\u003e [!IMPORTANT]\n\u003e On Windows, use gcc to compile your V program\n\u003e\n\u003e ```sh\n\u003e v -cc gcc your_awesome_program.v\n\u003e ```\n\n### Examples\n\n#### GET request\n\n```v\nimport vibe\n\n// Default request\nresp := vibe.get('https://hacker-news.firebaseio.com/v0/item/1.json')!\nprintln(resp.body)\n\n// Custom request\nrequest := vibe.Request{\n\theaders: {\n\t\t.user_agent: 'YourCustomUserAgent/v0.0.1'\n\t}\n}\nresp2 := request.get('https://hacker-news.firebaseio.com/v0/item/1.json')!\nprintln(resp2.body)\n```\n\n[`get_test`](https://github.com/ttytm/vibe/blob/main/src/_tests_get_test.v)\n\n#### POST request\n\n```v\nimport vibe\nimport time\n\nreq := vibe.Request{\n\theaders: {\n\t\t.user_agent:   'YourCustomUserAgent/v0.0.1'\n\t\t.content_type: 'application/json; charset=utf-8'\n\t}\n\ttimeout: time.second * 10\n}\n\nresp := req.post('https://httpbin.org/post', '{\"msg\":\"hello from vibe\"}')!\nprintln(resp)\n```\n\n[`post_test`](https://github.com/ttytm/vibe/blob/main/src/_tests_post_test.v)\n\n#### Download\n\n```v\nimport vibe\n\nvibe.download_file('https://github.com/vlang/v/releases/download/weekly.2023.23/v_linux.zip',\n\t'v_linux.zip')!\n```\n\n[`download_file_test`](https://github.com/ttytm/vibe/blob/main/src/_tests_download_file_test.v)\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eMore examples\u003c/b\u003e\u003c/summary\u003e\n\n\u003cbr\u003e\n\n#### GET Slice request\n\nIf optimizing speed is of concern when querying pages with large response bodies, and you know you\nonly need a portion of them, you can perform a `get_slice` request.\n\n```v oksyntax\n// Sends a GET request to the specified `url` and returns a slice of the response content.\n// Allocation of the received response as a vstring is postponed until the `start` byte position is reached.\n// The content is returned as soon as the slice reaches its `max_size` (offset from `start`)\n// - `max_size` can be `none` to return the remainder from the start.\npub fn (req Request) get_slice(url string, start usize, max_size ?usize) !Response\n```\n\n```v\nimport vibe\nimport net.html\n\nresp := vibe.get_slice('https://docs.vosca.dev/advanced-concepts/v-and-c.html', 65_000,\n\t10_000)!\nselector := html.parse(resp.body).get_tags_by_class_name('language-vmod')[0]\nprintln(selector.text())\n```\n\n[`get_slice_test`](https://github.com/ttytm/vibe/blob/main/src/_tests_get_slice_test.v)\n\n#### Download with progress\n\n```v oksyntax\n// Downloads a document from the specified `url` and saves it to the specified `file_path`.\n// `download` must implement a `progress(pos usize, size usize)`, and a `finish()` method.\npub fn (req Request) download_file_with_progress(url string, file_path string, download Download) !Response\n```\n\n```v\nimport vibe\nimport os\n\n// User-defined struct that implements the `Download` interface.\nstruct MyStruct {\n\tfoo string\n\tbar string\n}\n\nfn (dl MyStruct) progress(pos u64, size u64) {\n\tprint('\\rDownloading... ${f64(pos) / size * 100:.2f}%')\n\tos.flush()\n}\n\nfn (dl MyStruct) finish() {\n\tprintln('\\nDownload completed.')\n}\n\nmut download := MyStruct{}\nvibe.download_file_with_progress('https://github.com/vlang/v/releases/download/weekly.2023.23/v_linux.zip',\n\t'v_linux.zip', mut download)!\n```\n\n#### Persistent Cookie\n\nShare cookies between requests / sessions with a curl cookie jar file.\n\n\u003cem\u003eThe demo below does not provide real authentication data, for a \"full\" use-case scenario,\nchange the payload data and requested URLs to actual addresses that require authentication.\u003c/em\u003e\n\n```v\nimport vibe\nimport os\n\ncookie_jar := './demo_cookie'\n\nreq := vibe.Request{\n\theaders:    {\n\t\t.content_type: 'application/json; charset=utf-8'\n\t}\n\tcookie_jar: cookie_jar\n}\n\n// Login and save cookies to curl cookie file.\nreq.post('https://api.yourdomain.com/v1/login', '{\"username\":\"yourname\",\"password\":\"password\"}')!\n\n// Use the `cookie_file` in subsequent sessions to access endpoints that require the authentication above.\nreq2 := vibe.Request{\n\theaders:     {\n\t\t.content_type: 'application/json; charset=utf-8'\n\t}\n\tcookie_file: cookie_jar\n}\n\nresp := req2.get('https://api.yourdomain.com/v1/protected_page')!\n// ... use resp\n\n// Remove the cookie file or keep it for later usage.\nos.rm(cookie_jar)!\n```\n\n\u003c/details\u003e\n\n## Further information and upcoming features\n\nAdditional features will be added based on personal projects and sensible community needs.\nContributions like bug 🐛 reports, ⭐ stars and 💡 suggestions are welcome alike!\n\n### Planned\n\n- [x] Linux, macOS, Windows\n- [x] Download with progress\n- [x] Custom headers\n- [x] Proxy support\n\nGiven that the project is being worked on in limited spare time, please excuse potential delays in\nreplying.\n","funding_links":["https://ko-fi.com/tobealive"],"categories":["Libraries"],"sub_categories":["Networking"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttytm%2Fvibe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fttytm%2Fvibe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttytm%2Fvibe/lists"}