EventData API Notes

Save a Query
  • Endpoint: /eventdata/api/add-query
  • Method: POST, JSON data expected
  • Notes:
    • If not logged in, returns a `403` forbidden error
    • An individual user cannot use the same name twice for a saved query. See the details returned in the error messages.
    • An individual user cannot save a query more than once that has the same: query, collection, and collection_name. See the details returned in the error messages.
    • Saved under the name of the logged in user
    • Any extra fields sent in the request are ignored. e.g. the older "username" will not trigger an error, simply be ignored.
  • Example:
    
        {
           "name": "User entered query name",
           "description": "In this query I am ...."
           "query": [ "... mongo query, either list or dict ..." ],
           "collection_name": "acled_africa",
           "collection_type": "subset",
           "result_count": 161939,
        }
                

List a User's Queries
  • Endpoint: /eventdata/api/list
  • Test: /eventdata/api/list
  • Method: GET
  • Notes:
    • If not logged in, returns a `403` forbidden error
    • Returns queries saved by the logged in user
  • Example 1:
    
      {
        "success": true,
        "message": "list retrieved",
        "data": {
            "count": 4,
            "query_list": [
                {
                    "id": 4,
                    "name": "q12",
                    "description": "adfg",
                    "result_count": 161939,
                    "collection_name": "acled_africa",
                    "collection_type": "subset",
                    "hash_id": "992d7264200e3c73220bf430cdc0cef5d5a1469eebbd727aa358b98b",
                    "created": "2018-08-23T21:39:28.067790+00:00",
                    "modified": "2018-08-23T21:39:28.077061+00:00",
                    "username": "dev_admin",
                    "detail_url": "/eventdata/api/get/4"
                },
                ...etc...
            ]
        }
      }
            
  • Example 2:
    
      {
         "success":false,
         "message":"No saved queries found."
      }
                
  • Retrieve a single query for the logged in user
    • Endpoint: /eventdata/api/get/{query_id}
    • Method: GET
    • Example: /eventdata/api/get/34     (non-working)
    • Notes:
      • If not logged in, returns a `403` forbidden error
      • The query must be one saved by the logged in user
    • Examples: Same output as List a User's Queries

    Search a user's queries
    • Endpoint: /eventdata/api/search
    • Method: POST
    • Example: Run a search     (live example)
    • Notes:
      • If not logged in, returns a `403` forbidden error
      • Search parameters: name, description
      • Only queries are shown for the logged in user
    • Examples: Same output as List a User's Queries

    Delete a saved query
    • Endpoint:
      exampe query /eventdata/api/delete/{query_id}
    • Method: GET
    • Notes:
      • If not logged in, returns a `403` forbidden error
      • The query must have been saved by the logged in user or it will not be deleted. A 'no query found' message will be given.
    • Example 1:
      
        {
           "success":false,
           "message": "Query deleted."
        }
                      
    • Example 2:
      
        {
           "success":false,
           "message": "A query was not found for the given query id and user."
        }