Coder Social home page Coder Social logo

ipify-api's Introduction

ipify-api

A Simple Public IP Address API

This repository contains the source code for ipify, one of the largest and most popular IP address API services on the internet. ipify serves over 30 billion requests per month!

What does ipify do?

Have you ever needed to pragmatically get your public IP address? This is quite common for developers provisioning cloud servers, for instance, where you might be creating servers and running bootstrapping software on them without access to server metadata.

Being able to quickly and reliably get access to your public IP address is essential for configuring DNS, managing external services, and a number of other operationally related tasks.

In general, there are a number of uses for public IP address information.

What is ipify?

ipify is a free API service anyone can use to get their public IP address. It is highly reliable (built on top of Heroku) and fast. Typical response times (server side) are between 1ms and 10ms.

ipify is also fully funded -- it's been running for years and isn't going anywhere. The people behind ipify cover all expenses and maintenance, so you can feel safe integrating with it knowing it won't be disappearing.

If you'd like to use ipify in your application, no permission is needed. You can immediately start using the service without any restrictions. Simply visit our public website for more information.

What is this project?

This project is the source code that powers the ipify service. ipify is written in the Go programming language for speed and efficiency purposes. You can read an article written by ipify's creator, Randall Degges, if you'd like more information.

If you'd like to contribute to ipify's development, you can do so here. Pull requests are encouraged.

Finally, if you'd like to deploy your own instance of ipify, you can easily do so. Compiling this project will produce a single statically linked binary that is designed to be run on Heroku. With minor modification, ipify can be ran on any web hosting platform.

Please contact Randall if you need assistance deploying your own copy of ipify onto a non-Heroku host.

Building ipify

To develop and build ipify, you'll need to have the Go programming language setup on your computer. If you don't, you can read more about it here: https://golang.org/

Once you have Go installed, you'll need to clone this project into your computer's GOPATH. For me, this means I'll typically do something like:

$ git clone https://github.com/rdegges/ipify-api.git ~/go/src/github.com/rdegges/ipify-api

To build the project, change to the project directory and run:

$ go build

This will create the ipify-api binary in the current directory that you can use for testing.

Deploying ipify

If you'd like to deploy your own version of ipify to Heroku, you can do so easily by clicking the button below. This will take you to Heroku and let you instantly provision your own copy of the ipify service.

Deploy

Questions?

Got a question? Please create a Github issue!

ipify-api's People

Contributors

benyanke avatar rdegges avatar zcalusic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ipify-api's Issues

api6.ipify.org doesn't show IPv6.

I've been using ipify and I've noticed that my IPv6 only shows if I enter from Firefox, when I enter from Chrome or another browser it always shows my IPv4 even if I enter from api6.ipify.org

Thanks.

Add Docker support to the project

For ease of development and deployment, Docker support could be added to the project. This removes the need for dependencies on the developer's local machine (in this case, Go) and provides an easily portable container for developing and distributing.

Acceptance criteria

  • Add a Dockerfile and docker-compose.yml for development
  • Running docker-compose up runs the server successfully.

Expired SSL certificate (api.ipify.org)

Firstly apologies if this is not the right place to report this issue. I figured the alternative would be either to tweet or email you and out of these three options, this seemed most appropriate.

It seems the SSL certificate for api.ipify.org has expired today, 21/11/2016.

Cisco Security have blocked api.ipify.org using DNS RPZ

I was just using an application that was using your API (pretty cool idea, btw), and I noticed that it was failing because Cisco Security have blocked https://api.ipify.org using DNS RPZ. Specifically,

A hostname, network address, or nameserver associated with api.ipify.org has been manually identified by CSIRT as malicious or a security risk which has resulted in this block.

I'm a little surprised this has happened as you state you're served by Heroku, but I thought you may want to look into this.

More details on DNS RPZ here: https://blogs.cisco.com/security/using-dns-rpz-to-block-malicious-dns-requests

HTH :)

TBF, looking at #2 , I can't help but think that this is part of the same problem. :( But interestingly, it means that a web service that is (imo incorrectly) using api.ipify.org is completely broken for as long as I have Umbrella screening my DNS requests.

X-Fowarded-For

If a user sends a custom X-Forwarded-For header, this messes up the load balancer handling of the header. Need to debug this more to find a solution.

api6.ipify.org returns IPv4 address over IPv4

If one tries to request an IPv6 address from api6.ipify.org on a host that has no IPv6 connectivity, api6.ipify.org returns and IPv4 address.

Would be better to prevent that, e.g. simply by making sure api6.ipify.org does not have an A record in DNS, only AAAA. Currently it has both.

Perhaps also add measures against returning an IPv4 address when a v6 one is requested in code, and vice versa.

CORB blocked in Chrome.

Hi,

It looks like Chrome is blocking this service from being used in a webpage.

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://api.ipify.org/?format=json with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

I am pretty confused by Google's explanation at: https://chromium.googlesource.com/chromium/src/+/master/services/network/cross_origin_read_blocking_explainer.md

Because the JSON syntax is derived from and overlaps with JavaScript, care must be taken to handle the possibility of JavaScript/JSON polyglots. CORB handles the following cases for JSON:

Non-empty JSON object literal: A non-empty JSON object (such as {"key": "value"}). This is precisely the subset of JSON syntax which is invalid JavaScript syntax -- the colon after the first string literal will generate a syntax error. CORB can protect these cases, even if labeled with a different Content-Type, by sniffing the response body.

Uhhhhhhhhhhhhhhhhhhhhhhh..........isn't that the wrong way round? That {"key": "value"} is valid as both JSON and as a JS object. It would be {key: "value"} that is valid JS object, but not valid JSON.

The code I'm using on a webpage is as follows. It doesn't reach the success callback as response.json fails, due to the response being empty.

    const params = {
      mode: 'no-cors',
      redirect: "follow",
      referrer: "no-referrer"
    };

    fetch('https://api.ipify.org/?format=json', params)
      .then(response => response.json())
      .then(successCallback)
      .catch(failCallback);

support cors

basically allow getting ip address without the need of jsonp.

api.ipify.org shows wrong IP

On ipify.org:

$ curl 'https://api.ipify.org?format=json'
{"ip":"46.x.x.17"}

46.x.x.17 is my correct external IP. This is also what https://ident.me/ shows.

On api.ipify.org:

172.16.x.x

This is the internal/local IP.

{"ip": "<nil>"} returned when supplying callback parameter

Hi,

When I hit the service with say
https://api.ipify.org/?format=jsonp

I get back as expected:
callback({"ip":"195.xxx.xxx.xxx"});

However if I add the "callback" parameter, for example
http://api.ipify.org/?format=jsonp&callback=jq

...then I get back:
jq({"ip":"\u003cnil\u003e"});

Why? Is this a bug?

IPv4 - two IP address

your api shows me two IP addresses. one is the right and the other (185.103.110.182).
I would like to answer. No VPN or proxy.

Random Heroku HTML application error response

Occasionally (reasonably often) the ipify API will return some application error HTML generated by Heroku instead of an IP.

For example:

<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta charset="utf-8"> <title>Application Error</title> <style media="screen"> html,body,iframe { margin: 0; padding: 0; } html,body { height: 100%; overflow: hidden; } iframe { width: 100%; height: 100%; border: 0; } </style> </head> <body> <iframe src="//www.herokucdn.com/error-pages/application-error.html"></iframe> </body> </html><!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta charset="utf-8"> <title>Application Error</title> <style media="screen"> html,body,iframe { margin: 0; padding: 0; } html,body { height: 100%; overflow: hidden; } iframe { width: 100%; height: 100%; border: 0; } </style> </head> <body> <iframe src="//www.herokucdn.com/error-pages/application-error.html"></iframe> </body> </html><!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta charset="utf-8"> <title>Application Error</title> <style media="screen"> html,body,iframe { margin: 0; padding: 0; } html,body { height: 100%; overflow: hidden; } iframe { width: 100%; height: 100%; border: 0; } </style> </head> <body> <iframe src="//www.herokucdn.com/error-pages/application-error.html"></iframe> </body> </html><!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta charset="utf-8"> <title>Application Error</title> <style media="screen"> html,body,iframe { margin: 0; padding: 0; } html,body { height: 100%; overflow: hidden; } iframe { width: 100%; height: 100%; border: 0; } </style> </head> <body> <iframe src="//www.herokucdn.com/error-pages/application-error.html"></iframe> </body> </html>

When running in a shell script this is annoying to handle correctly -- on application errors, I'd rather see a blank response than this.

Add License

I know you have this labeled as open source on the website, but adding a license will help others when modifying it and such.

Api is logging user information

On www.ipify.org it says

No visitor information is ever logged. Period.

however, the code has this line

fmt.Fprintln(os.Stderr, "WOOT:", r.Header.Get("X-Forwarded-For"))

which on heroku effectively logs every request made to the api.
Is this code a misplaced debug or is the website incorrect?

Licensing

Would you consider dual-licensing this under the MIT and Unlicense? My company tries to steer clear of the Unlicense.

Error status: -1

Hi, first off, thanks for this service!

For 2 days, some web clients have this error:

{
    "data": null,
    "status": -1,
    "config": {
        "method": "GET",
        "transformRequest": [null],
        "transformResponse": [null],
        "url": "https://api.ipify.org?format=json",
        "headers": {
            "Accept": "application/json, text/plain, */*"
        }
    },
    "statusText": ""
}

Could you tell me why?

Thank you very much.

Cache Headers

Would be nice to include cache headers to prevent odd behavior from some ISPs:

Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0

404 errors

We regularly get 404 responses when calling https://api.ipify.org?format=jsonp&callback=JSON_CALLBACK. We use the service in our client code, so it might be an issue on our customers' machines. Do you have any explanation what might cause it?

Your current data: {"ip": "<nil>"}

The api URL seems to be giving me a text result of:
<nil>
from the command
wget http://api.ipify.org -4 -q -O -

As json curl 'http://api.ipify.org?format=json' gives {"ip":"\u003cnil\u003e"}

If I were to guess I'd say it might be something to do with a header I add ... X-Forwarded-for 192.0.2.1 but that's not certain.

i get an http code =-1

hello i try to use your api with the EasyDDNS library for arduino... i was trying to check my ip address and update my ddns acount with it.. it seems though that your api returns me an error -1 http code and i cannot get my ip address..
i run this on a Node Mcu Lua Esp8266 if this helps..

suggestion

Hello,
i appreciate your work because it's stable, simple and easy to use
and it will really be great & perfect if you ll add Country Localization feature
Thank you

Random SSL wrong version error at https://api6.ipify.org

When querying https://api6.ipify.org, about one out of 3 of requests end up with SSLError WRONG_VERSION_NUMBER. Here is such instance:

wget https://api6.ipify.org --2021-02-28 18:34:21-- https://api6.ipify.org/ Resolving api6.ipify.org (api6.ipify.org)... 2607:f2d8:4010:c::2, 2607:f2d8:4010:8::2, 2607:f2d8:4010:b::2 Connecting to api6.ipify.org (api6.ipify.org)|2607:f2d8:4010:c::2|:443... connected. GnuTLS: An unexpected TLS packet was received. Unable to establish SSL connection.
As seen above the address api6.ipify.org resolves to 2607:f2d8:4010:c::2, 2607:f2d8:4010:8::2, 2607:f2d8:4010:b::2. The server at address 2607:f2d8:4010:c::2 yields the error, while the other 2 connect correctly and return the answer.

api.ipify.org: Root Certificate Expired May 30th

It seems one of the root/intermediate certificates for api.ipify.org have expired on May 30th 2020.

Ths certificate itself is valid but the intermediates seem to no longer validate. From browsers, this will look transparent but from machines/curl/node call it will show as an invalid certificate. We are currently hitting this from a node/electron application when trying to use api.ipify.org.

Relevant links:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.