second-state/smart-contract-search-engine

Create documentation on how to query API

tpmccallum opened this issue · 2 comments

Users can visit the search engine and search using words and addresses. In addition to this machines can also query the search engine programmatically.

For example
Curl
Using curl in the command line

curl -X GET "http://54.252.157.165/api/data1" -H 'Content-Type: application/json' -d' {"query": {"match": {"contractAddress": "0x0fEB15a0F7029b0F4aF355aa2Fc3CFa6Df7C8483"}}}'

Javascript

_data = {
    "query": {
        "match_all": {}
    }
}
var _dataString = JSON.stringify(_data);
$.ajax({
    url: "http://54.252.157.165/api/data2",
    type: "POST",
    data: _dataString,
    dataType: "json",
    contentType: "application/json",
    success: function(response) {
        console.log(response);
    },
    error: function(xhr) {
        console.log("Get items failed");
    }
});

For example the Javascript code above will return the following
Screen Shot 2019-05-29 at 11 47 18 AM

This page now has examples and links to resources which will facilitate all querying.
https://github.com/second-state/smart-contract-search-engine/blob/master/documentation/usage.md