
got Has a Free API — Here's How to Use This Feature-Rich HTTP Client for Node.js
got is a human-friendly and powerful HTTP request library for Node.js. It supports retries, streams, pagination, caching, and more — making it ideal for building robust API integrations. Installation npm install got Basic Requests import got from " got " ; // GET with JSON parsing const data = await got ( " https://api.github.com/repos/sindresorhus/got " ). json (); console . log ( ` ${ data . full_name } : ${ data . stargazers_count } stars` ); // POST with JSON body const response = await got . post ( " https://httpbin.org/post " , { json : { tool : " got " , version : 14 } }). json (); Instances with Defaults const api = got . extend ({ prefixUrl : " https://api.example.com/v2 " , headers : { " Authorization " : " Bearer token " }, retry : { limit : 3 }, timeout : { request : 10000 }, responseType : " json " }); const users = await api . get ( " users " ). json (); const user = await api . post ( " users " , { json : { name : " New " } }). json (); Pagination — Auto-Fetch All Pages
Continue reading on Dev.to Webdev
Opens in a new tab

