Skip to content

Instantly share code, notes, and snippets.

@robinbraemer
Last active September 12, 2022 17:08
Show Gist options
  • Select an option

  • Save robinbraemer/716cd5066f038aa95146766fb588fecf to your computer and use it in GitHub Desktop.

Select an option

Save robinbraemer/716cd5066f038aa95146766fb588fecf to your computer and use it in GitHub Desktop.
Free ipinfo.io Business plan features

How to use ipinfo.io business plan features for free

! THIS GIST IS FOR INFORMATION PURPOSES ONLY. USE AT YOUR OWN RISK !

It uses the /widget/demo endpoint that is shown on the landing page of ipinfo which returns results only available in business plan.

The following shows the available API endpoints. You should look at the code below to make requests on your own instead of using my demo Cloudflare Worker. Because Cloudflare Workers use shared IPs the ipinfo API rate limits too many requests from the same IP and sometimes returns a 429 Too Many Requests.

addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const reqURL = new URL(request.url);
if (reqURL.pathname == "/") {
return new Response("missing path", { status: 400 });
}
// Forward the request to the demo api...
const newURL = "https://ipinfo.io/widget/demo" + reqURL.pathname
const newURLStr = newURL.toString()
console.log(newURLStr)
const modifiedRequest = new Request(newURLStr, {
body: request.body,
headers: new Headers({
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
"content-type": "application/json",
"referer": "https://ipinfo.io/",
}),
method: request.method,
redirect: request.redirect,
})
return fetch(modifiedRequest)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment