Query Data with Playground

Say that you're interested in how coins are transferred to BitCoin wallet 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa. Without OCAP service, you probably need to setup your own bitcoin node, learn its RPC, and then write code to get that information, you could do that easily with OCAP service:

{
  transactionsByAddress(receiver: "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa", paging: {size: 10}) {
    data {
      historyPrice
      priceInUsd
      time
      blockHeight
      hash
      total
      inputs {
        data {
          script
          scriptType
        }
      }
      outputs {
        data {
          script
          scriptType
          index
        }
      }
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

This is a GraphQL query. Basically it says: give 10 transactions whose receiver is 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa with the fields I want. If you find the query is hard to understand you could jump to quick tour to public chains.

You can copy this query and paste it to the query editor at https://ocap.arcblock.io. hit run button, then you'll get:

{
  "data": {
    "transactionsByAddress": {
      "data": [
        {
          "total": 590677,
          "time": "2018-11-11T17:55:55.323Z",
          "priceInUsd": 5566.4042687225,
          "outputs": {
            "data": [
              {
                "scriptType": "P2PKH",
                "script": "76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac",
                "index": 0
              },
              {
                "scriptType": "P2PKH",
                "script": "76a914a8ab0fa7c037ca461cb7790cca029df50b41243e88ac",
                "index": 1
              }
            ]
          },
          "inputs": {
            "data": [
              {
                "scriptType": "P2PKH",
                "script": "47304402206cd4691e8a75848fe32a4b3a13cabe154c8532d92bab1d469d45999b3269718f02204fdcc949b949bbe896baa7f6654100bcb9936f32ea9c66f2c7d1765cddfc168c01210260fad7afe4c6b666cdabc95f1bfbe4a246535bd582bd98219de570a7fcea2e05"
              }
            ]
          },
          "historyPrice": "6350.17",
          "hash": "f706263ff144468af269d8ec3745b2fa9f615f19e8368da99a4d7b4379fc5885",
          "blockHeight": 549694
        }
        ...
      ]
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

This is a standard response from our OCAP service. If the query is valid and we can find the related data, the result will be in data. Otherwise, an error field will describe what's wrong with the query.

The whole process described above can be visualized in following screenshot:

Pretty simple huh?

Want to query a block information? Or just an transaction? All these data types are supported with different APIs by OCAP service, you can go to OCAP Playground. Learn more about OCAP Playground Quick Start Tour.

Last Updated: 11/30/2018, 10:39:27 AM