Gadfly API Documentation - ProjectGadfly/WebServer GitHub Wiki

Gadfly API Documentation

For every API, it needs the correct key in its "APIKey" header.

GET /services/v1/representatives?address={address}

Description: Gets information on senators and representatives given an address. There are many formats of addresses that a user can input. We won't bother with the complications of various inputted addresses. Thus, this API will give a best estimate with a given address. Future versions that are more inclusive to other governmental systems may have a tagging system rather than booleans for the representative's political role.

Note: Special characters will need to be URL-encoded prior to being passed as an address parameter.

Parameters:

  • address: Required, address: string

Returns:

  • if google doesn't return anything, {'Status':'invalid address'}
  • if address not in US, {'Status':'address should be in US'}
  • if address too broad, like "United States", {'Status':'address too broad'}
  • if succeed,
         {
            'Status':'OK'
            'Results':[
        	{
        		'name': string,
        		'phone': integer,nullable
        		'picURL': string,nullable
        		'email': string,nullable
        		'party': string,
        		'tags': [list of tag_ids(int)]
        	},
                       {Another Rep},
                       {Another Rep},
                       {Another Rep},
                       ...
                       ...
           ]
         }
    
    

GET /services/v1/id?ticket={ticket}

Description: Gets the ID of a call script given a ticket

Parameters:

  • ticket: Required, ticket: string

Returns:

  • if no corresponding ID exists, {'Status':'No such ticket'}
  • if failed anyway, {'Status':'Failed to get id'}
  • if succeed, {'Status':'OK','id':int}

GET /services/v1/script?id={ID}

Description: Gets a specific call script given a script ID.

Parameters:

  • ID: Required, ID: integer

Returns:

  • if no corresponding ID exists, {'Status':'No such id'}
  • if failed anyway, {'Status':'Failed to get script'}
  • if succeed,
        {
          'Status':'OK'
          'Script':{ 
               'title': string,
           'content': string,
               'tags':[list of tag_ids(int)]
       }
         }
    
    

POST /services/v1/script

Description: Posts a new script given information inputted by a user. This process will be done by activists through the website. When the script is created, it will have a script ID for our database. The QR code will be created by this script ID. A ticket, 32-character BASE64 string, will also be produced. This ticket will be in the unique URL to that script for the activist to access if they want to delete it in the future.

Parameters:

  • script: Required, a form

          
            title=string,
        content=string,
        tags=[list of tag_ids(int)]
    
    
    

Returns:

  • if failed, {'Status':'Failed to post'}
  • if succeed, {'Status':'OK', 'ticket': string, 'id': int}

DELETE /services/v1/script?ticket={ticket}

Description: Deletes script given a ticket. The ticket is internally tied to the script ID. This will allow script-writers to "edit" or delete their script.

Parameters:

  • ticket: Required, ticket: string

Returns:

  • if failed, {'Status':'Deletion Failed'}
  • if succeed, {'Status':'OK'}

GET /services/v1/alltags

Description: Returns all tag names and tag id's for use in building UI elements

Returns:

  • if succeed, returns a JSON string where keys are tag_id and values are tag_name,

    {'1': 'federal', '2': 'state', '3': 'senator', '4': 'representative'}