<p>Sounds like you are looking for the <code>listtransactions</code> API call in combination with the <code>category</code> field. </p>

<p>First argument is for a specific account, use * to return all accounts.<br>
2nd is how many you want to return.<br>
3rd is if you want to skip transaction from the start.<br>
4th argument is if you want to include watch-only addresses.    </p>

<p><code>$bitcoin-&gt;listtransactions("*", 100, 0, false);</code></p>

<p>Example output (note the category field):     </p>

<pre><code>{
"result": [
    {
        "account": "",
        "address": "32NFcoB96ANoPnqycLH9WUd94o7bwRyq66",
        "category": "receive",
        "amount": 0.00385000,
        "label": "",
        "vout": 1,
        "confirmations": 24827,
        "blockhash": "000000000000000000250cffa73c2a08e64e53dab398ede3f38b1c30ae5c66ca",
        "blockindex": 317,
        "blocktime": 1529098309,
        "txid": "07b1d3fbc4d78d480d510264bb01bd390e81cda34dcb01e882e94adfa9355d10",
        "walletconflicts": [

        ],
        "time": 1529098115,
        "timereceived": 1529098115,
        "bip125-replaceable": "no"
    }
],
"error": null,
"id": null
}
</code></pre>

CC BY-SA 4.0
2018-12-04T09:16:01.343Z
sorry but how can i categorise all transactions ? With above results its mixed transactions of send and receive .Also i cant get the total count of all transactions
Pankaj Kumar
CC BY-SA 4.0
2018-12-04T16:49:10.900Z
You need to filter the result yourself by looking at the category.
Ava Chow
CC BY-SA 4.0
2018-12-05T04:27:53.987Z
Andrew but i can understand that i have to filter result , but one thing i cant understand that how can i count the total transactions , as there is no count attribute return by the listransactions rpc call
Pankaj Kumar
CC BY-SA 4.0
2018-12-05T06:21:56.277Z
Andrew can you please check if the above logic is correct or not
Pankaj Kumar
CC BY-SA 4.0
2018-12-08T06:30:40.207Z
As achow mentions you need to add that yourself. Create a simple loop and then check to see if `category` equals `send` or `receive`, then output your data as you like.
m1xolyd1an
CC BY-SA 4.0
2018-12-04T03:51:53.947Z
2018-12-04T03:51:53.947Z
m1xolyd1an
<pre><code>    from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
import logging
RPC_USER, RPC_PWD,URL,PORT="RPC_USER","RPC_PWD","URL","PORT"


CONN="http://%s:%s@%s:%s"%(RPC_USER, RPC_PWD,URL,PORT)
try:
    rpc_connection = AuthServiceProxy(CONN) 
    start=10
    end=0
    count=0 
    receive=[]
    send=[]
    while True:
        trans=rpc_connection.listtransactions("prologic",10,end)
        for tran in trans:                  
            if(tran['category'] == "receive"):
                receive.insert(0,tran)              
            else:
                send.insert(0,tran)
        if(len(trans) is 0):
            break
        else:
            end=end+10
            count=count+len(trans)


    all_trans={"total":count,"receive":{"count":len(receive),"trans":receive},"send":{"count":len(send),"trans":send}}
    print(all_trans)

except Exception as e:
    print (str(e))
</code></pre>

CC BY-SA 4.0
2018-12-05T06:20:10.953Z
2018-12-05T06:20:10.953Z
Pankaj Kumar
<p>I am creating new wallet for bitcoin and want to know how we can get the separate list of send and receive transactions using JSON rpc.</p>

<p>I cant see any method for json rpc that give list of send and receive category </p>

CC BY-SA 4.0
2018-12-03T11:27:11.803Z
are you searching for  sendtoaddress rpc?
Parishilan Rayamajhi
CC BY-SA 4.0
2018-12-03T11:40:59.827Z
no , i am looking for the way to get list of sent and receive transactions ,listtransactions returning send and receive list , i want to get separate list of sent and recieve
Pankaj Kumar
CC BY-SA 4.0
2018-12-03T12:26:50.290Z
you need to find it out through VOUT and VIN list
Parishilan Rayamajhi
CC BY-SA 4.0
2018-12-03T12:41:48.267Z
is that means there is no separate rpc call for getting the sent and receive for particular account label ?
Pankaj Kumar
CC BY-SA 4.0
2018-12-03T12:55:38.303Z
listunspent : version 0.7 Returns array of unspent transaction inputs in the wallet. 
source : https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list
Parishilan Rayamajhi
CC BY-SA 4.0
2018-12-03T13:01:11.980Z
sorry but its not have any parameters that differentiate the accounts. i need a way so that on the basis of accounts label i have the sent and receive transactions list
Pankaj Kumar
CC BY-SA 4.0
2018-12-04T09:11:46.297Z
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/86589/discussion-between-pankaj-kumar-and-cryptoktm).
Pankaj Kumar
<json-rpc><bitcoin-cli>
how to split transactions based on send and receive Json rpc bitcoin
Pankaj Kumar
# how to split transactions based on send and receive Json rpc bitcoin

(Asked by: username_0 on 2018-12-03)

I am creating new wallet for bitcoin and want to know how we can get the separate list of send and receive transactions using JSON rpc.

I cant see any method for json rpc that give list of send and receive category

**Tags:** json-rpc, bitcoin-cli

> **Comments:**
> **username_1**: are you searching for  sendtoaddress rpc?  
> **username_0**: no , i am looking for the way to get list of sent and receive transactions ,listtransactions returning send and receive list , i want to get separate list of sent and recieve  
> **username_1**: you need to find it out through VOUT and VIN list  
> **username_0**: is that means there is no separate rpc call for getting the sent and receive for particular account label ?  
> **username_1**: listunspent : version 0.7 Returns array of unspent transaction inputs in the wallet.  source : https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list  
> **username_0**: sorry but its not have any parameters that differentiate the accounts. i need a way so that on the basis of accounts label i have the sent and receive transactions list  
> **username_0**: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/86589/discussion-between-username_0-username_0-and-cryptoktm).  

---

## 2 answers

### Answer by username_2 on 2018-12-04. Score: 1

Sounds like you are looking for the `listtransactions` API call in combination with the `category` field.

First argument is for a specific account, use \* to return all accounts.  
2nd is how many you want to return.  
3rd is if you want to skip transaction from the start.  
4th argument is if you want to include watch-only addresses.

`$bitcoin->listtransactions("*", 100, 0, false);`

Example output (note the category field):

```
{
"result": [
    {
        "account": "",
        "address": "32NFcoB96ANoPnqycLH9WUd94o7bwRyq66",
        "category": "receive",
        "amount": 0.00385000,
        "label": "",
        "vout": 1,
        "confirmations": 24827,
        "blockhash": "000000000000000000250cffa73c2a08e64e53dab398ede3f38b1c30ae5c66ca",
        "blockindex": 317,
        "blocktime": 1529098309,
        "txid": "07b1d3fbc4d78d480d510264bb01bd390e81cda34dcb01e882e94adfa9355d10",
        "walletconflicts": [

        ],
        "time": 1529098115,
        "timereceived": 1529098115,
        "bip125-replaceable": "no"
    }
],
"error": null,
"id": null
}

```

> **Comments:**
> **username_0**: sorry but how can i categorise all transactions ? With above results its mixed transactions of send and receive .Also i cant get the total count of all transactions  
> **username_3**: You need to filter the result yourself by looking at the category.  
> **username_0**: Andrew but i can understand that i have to filter result , but one thing i cant understand that how can i count the total transactions , as there is no count attribute return by the listransactions rpc call  
> **username_0**: Andrew can you please check if the above logic is correct or not  
> **username_2**: As achow mentions you need to add that yourself. Create a simple loop and then check to see if `category` equals `send` or `receive`, then output your data as you like.  

---

### Answer by username_0 on 2018-12-05. Score: 0

```
    from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
import logging
RPC_USER, RPC_PWD,URL,PORT="RPC_USER","RPC_PWD","URL","PORT"

CONN="http://%s:%s@%s:%s"%(RPC_USER, RPC_PWD,URL,PORT)
try:
    rpc_connection = AuthServiceProxy(CONN) 
    start=10
    end=0
    count=0 
    receive=[]
    send=[]
    while True:
        trans=rpc_connection.listtransactions("prologic",10,end)
        for tran in trans:                  
            if(tran['category'] == "receive"):
                receive.insert(0,tran)              
            else:
                send.insert(0,tran)
        if(len(trans) is 0):
            break
        else:
            end=end+10
            count=count+len(trans)

    all_trans={"total":count,"receive":{"count":len(receive),"trans":receive},"send":{"count":len(send),"trans":send}}
    print(all_trans)

except Exception as e:
    print (str(e))

```


---

