{"id":77,"date":"2023-04-29T22:43:57","date_gmt":"2023-04-30T03:43:57","guid":{"rendered":"https:\/\/complyctrl.com\/?p=77"},"modified":"2024-07-16T11:20:54","modified_gmt":"2024-07-16T16:20:54","slug":"httpx","status":"publish","type":"post","link":"https:\/\/complyctrl.com\/index.php\/2023\/04\/29\/httpx\/","title":{"rendered":"httpx"},"content":{"rendered":"\n<p>HTTPX is a fully featured HTTP client library for Python 3, which provides sync and async APIs, and support for both HTTP\/1.1 and HTTP\/2.<\/p>\n\n\n\n<p>It is a drop-in replacement for the standard Python <code>requests<\/code> library and provides additional features such as HTTP\/2 support, HTTP\/2 server push, connection pooling, thread-safe connection management, and more.<\/p>\n\n\n\n<p>HTTPX is designed to be easy to use, flexible, and performant, making it a great choice for building web applications and APIs.<\/p>\n\n\n\n<p>To use HTTPX, you first need to install it using pip:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install httpx\n\n<\/code><\/pre>\n\n\n\n<p>Then, you can import it and start making HTTP requests. Here&#8217;s an example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import httpx\n\nresponse = httpx.get(\"&lt;https:\/\/www.example.com&gt;\")\nprint(response.status_code)\nprint(response.text)\n\n<\/code><\/pre>\n\n\n\n<p>You can also use HTTPX&#8217;s async API for async requests. Here&#8217;s an example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import httpx\n\nasync def main():\n    async with httpx.AsyncClient() as client:\n        response = await client.get(\"&lt;https:\/\/www.example.com&gt;\")\n        print(response.status_code)\n        print(response.text)\n\nasyncio.run(main())\n\n<\/code><\/pre>\n\n\n\n<p>HTTPX also provides many additional features, such as support for timeouts, authentication, cookies, proxies, and more. Check out the <a href=\"https:\/\/www.python-httpx.org\/\">official documentation<\/a> for more information.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>HTTPX is a fully featured HTTP client library for Python 3, which provides sync and async APIs, and support for both HTTP\/1.1 and HTTP\/2. It is a drop-in replacement for the standard Python requests library and provides additional features such as HTTP\/2 support, HTTP\/2 server push, connection pooling, thread-safe connection management, and more. HTTPX is [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[14],"tags":[],"class_list":["post-77","post","type-post","status-publish","format-standard","hentry","category-tools"],"_links":{"self":[{"href":"https:\/\/complyctrl.com\/index.php\/wp-json\/wp\/v2\/posts\/77","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/complyctrl.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/complyctrl.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/complyctrl.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/complyctrl.com\/index.php\/wp-json\/wp\/v2\/comments?post=77"}],"version-history":[{"count":1,"href":"https:\/\/complyctrl.com\/index.php\/wp-json\/wp\/v2\/posts\/77\/revisions"}],"predecessor-version":[{"id":78,"href":"https:\/\/complyctrl.com\/index.php\/wp-json\/wp\/v2\/posts\/77\/revisions\/78"}],"wp:attachment":[{"href":"https:\/\/complyctrl.com\/index.php\/wp-json\/wp\/v2\/media?parent=77"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/complyctrl.com\/index.php\/wp-json\/wp\/v2\/categories?post=77"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/complyctrl.com\/index.php\/wp-json\/wp\/v2\/tags?post=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}