Skip to content
Harsh Daftary edited this page Aug 21, 2016 · 2 revisions

Common

  • API HOST URL : http://<domain>:<port>/rpc/json
  • HTTP headers : {'Content-type': 'application/json'}
  • API method : POST

JSON methods :

  1. add_url :

    • Request JSON Body :
      {'method': 'add_url', 'params': ['<URL including http or https>'], 'id': "jsonrpc"}
    • Response Code: 200
    • Response Body : {'result' : '<shortened_key>', 'error' : false}
  2. add_static_url :

    • Request JSON Body :
      {'method': 'add_static_url', 'params': ['<URL>', '<KEYWORD'], 'id': "jsonrpc"}
    • Response Code: 200
    • Response Body : {'result' : '<shortened_Key>', 'error' : false}
  3. get_url :

    • Request JSON Body :
      {'method': 'get_url', 'params': ['<shortened_key>'], 'id': "jsonrpc"}
    • Response Code: 200
    • Response Body : {'result' : '<URL>', 'error' : false}

Additional Details :

  • Error description will be given in error field of JSON Response with response code other than 200.
  • Static URL is very similar to add_url with main difference is that instead of random key generated by add_url here key is pre-determined.
  • sqlalchemy.Integer is not supported with postgres hence PGBigInteger or BIGINT is used.
  • update_url function will update static_url mapping of static_id and mapped URL.
  • Change production_mode = False to True in godebian/config.py to use Production Level config file.
  • Convert a mapping object or a sequence of two-element tuples to a “percent-encoded” string, suitable to pass to urlopen() above as the optional data argument.

IP restriction :

  • The IP class allows a comfortable parsing and handling for most notations in use for IPv4 and IPv6 addresses and networks.
  • It was greatly inspired by RIPE's Perl module NET::IP's interface but doesn't share the implementation.
  • It doesn't share non-CIDR netmasks, so funky stuff like a netmask of 0xffffff0f can't be done here.