update-api.rst 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. IP Update API
  2. ~~~~~~~~~~~~~
  3. In case you want to dig deeper, here are the details on how our IP update API
  4. works. We provide this API to be compatible with
  5. most dynDNS clients. However, we also provide a RESTful API that is
  6. more powerful and always preferred over the legacy interface described here.
  7. Update Request
  8. ``````````````
  9. An IP updates is performed by sending a GET request to ``update.dedyn.io`` via
  10. HTTP or HTTPS. The path component can be chosen freely as long as it does not
  11. end in ``.ico`` or ``.png``.
  12. You can connect via IPv4 or IPv6. To enforce IPv6, use ``update6.dedyn.io``.
  13. Please be aware that while we still accept unencrypted requests, we **urge**
  14. you to use HTTPS. For that reason, we also send an HSTS header on HTTPS
  15. connections.
  16. Authentication
  17. **************
  18. You can authenticate your client in several ways:
  19. - Preferred method: HTTP Basic Authentication. Encode your username and
  20. password as provided upon registration in the ``Authorization: Basic ...``
  21. header. This is the method virtually all dynDNS clients use out of the box.
  22. - REST API method: HTTP Token Authentication. Send an ``Authorization: Token
  23. ...`` header along with your request, where ``...`` is an API token issued
  24. for this purpose. This method is used by our REST API as well.
  25. - Set the ``username`` and ``password`` query string parameters (``GET
  26. ?username=...&password=...``). We **strongly discourage** using this
  27. method, but provide it as an emergency solution for situations where folks
  28. need to deal with old and/or crappy clients.
  29. If we cannot authenticate you, the API will return a ``401 Unauthorized``
  30. status code.
  31. Determine Hostname
  32. ******************
  33. To update your IP address in the DNS, our servers need to determine the
  34. hostname you want to update (it's possible to set up several domains). To
  35. determine the hostname, we try the following steps until there is a match:
  36. - ``hostname`` query string parameter, unless it is set to ``YES`` (this
  37. sometimes happens with dynDNS update clients).
  38. - ``host_id`` query string parameter.
  39. - The username as provided in the HTTP Basic Authorization header.
  40. - The username as provided in the ``username`` query string parameter.
  41. - After successful authentication (no matter how), the only hostname that is
  42. associated with your user account (if not ambiguous).
  43. If we cannot determine a hostname to update, the API will return a ``404 Not
  44. Found`` status code.
  45. .. _determine-ip-addresses:
  46. Determine IP addresses
  47. **********************
  48. The last ingredient we need for a successful update of your DNS records is your
  49. IPv4 and/or IPv6 addresses, for storage in the ``A`` and ``AAAA`` records,
  50. respectively.
  51. For IPv4, we will use the first IPv4 address it can find in the query string
  52. parameters ``myip``, ``myipv4``, ``ip`` (in this order). If none of them is
  53. set, it will use the IP that connected to the API, if a IPv4 connection was
  54. made. If no address is found or if an empty value was provided instead of an IP
  55. address, the ``A`` record will be deleted from the DNS.
  56. For IPv6, the procedure is similar. We check ``myipv6``, ``ipv6``, ``myip``,
  57. ``ip`` query string parameters (in this order) and the IP that was used to
  58. connect to the API for IPv6 addresses and use the first one found. If no
  59. address is found or an empty value provided instead, the ``AAAA`` record will
  60. be deleted.
  61. Update Response
  62. ```````````````
  63. If successful, the server will return a response with status ``200 OK`` and
  64. ``good`` as the body (as per the dyndns2 protocol specification). For error
  65. status codes, see above.