# Extracting Data from TTN to my Server

**URL:** <https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920>\
**Category:** Application Development\
**Created:** [April 26, 2017, 7:21am UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920 "2017-04-26T07:21:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![LoraWANSMARU](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/l/7ea924/32.png) [@LoraWANSMARU](https://www.thethingsnetwork.org/forum/u/LoraWANSMARU)\
**Post date:** [April 26, 2017, 7:21am UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/1 "2017-04-26T07:21:36Z")

</div>

I have successfully integrated my nodes and gateway to TTN and they are now transferring data easily. I need to know how can I extract data from TTN and send the same to my server?  
Is there any API provided by TTN?  
Kindly help with any information.

Thank you

---

<div class="post-metadata">

**Author:** ![celiagarridoh](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/celiagarridoh/32/37579_2.png) [@celiagarridoh](https://www.thethingsnetwork.org/forum/u/celiagarridoh)\
**Post date:** [April 26, 2017, 7:29am UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/2 "2017-04-26T07:29:59Z")

</div>

Hi,

As far as I know you can use several MQTT clients provided by TTN. Here I leave you some information on this:

[https://www.thethingsnetwork.org/docs/applications/mqtt/](https://www.thethingsnetwork.org/docs/applications/mqtt/)

I’m in the same point right now. I’ll use the Node.JS SDK to receive uplink messages in my own server. I hope this is useful for you.

Regards,  
Celia

---

<div class="post-metadata">

**Author:** ![jdelaet](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jdelaet/32/8164_2.png) [@jdelaet](https://www.thethingsnetwork.org/forum/u/jdelaet)\
**Post date:** [April 26, 2017, 7:58am UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/3 "2017-04-26T07:58:34Z")

</div>

Have a look here: [https://www.thethingsnetwork.org/docs/applications/integrations.html](https://www.thethingsnetwork.org/docs/applications/integrations.html).  
The HTTP integration might be an option for you as well. It works for me (server with php and mysql).

---

<div class="post-metadata">

**Author:** ![LoraWANSMARU](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/l/7ea924/32.png) [@LoraWANSMARU](https://www.thethingsnetwork.org/forum/u/LoraWANSMARU)\
**Post date:** [April 26, 2017, 10:36am UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/4 "2017-04-26T10:36:59Z")

</div>

Thanks a lot Celia!

Regards,  
Zaheen

---

<div class="post-metadata">

**Author:** ![ayarialadin](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@ayarialadin](https://www.thethingsnetwork.org/forum/u/ayarialadin)\
**Post date:** [April 27, 2017, 4:34pm UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/5 "2017-04-27T16:34:11Z")

</div>

> [@celiagarridoh](#):
>
> I’m in the same point right now. I’ll use the Node.JS SDK to receive uplink messages in my own server. I hope this is useful for you.

Hi celiagarridoh, can you see the recieved messages on your server ( what you are getting in the frames as payloads sent from the object ), cause that’s my problem, when i see the statu of the gateway, it shows me the number of the forwarded frames to the server but it doesn’t show me what the server is recieving as payloads, does your solution solve my problem ?

---

<div class="post-metadata">

**Author:** ![celiagarridoh](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/celiagarridoh/32/37579_2.png) [@celiagarridoh](https://www.thethingsnetwork.org/forum/u/celiagarridoh)\
**Post date:** [April 27, 2017, 8:40pm UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/6 "2017-04-27T20:40:07Z")

</div>

Hi @ayarialadin,

I’m not sure I understand your problem… You don’t see the messages from your node (application) in your own server, right?

I have a Node.js server running and I’m receiving there the data from my application in TTN, if this is what you want let me know and I’ll help you 🙂

Regards,  
Celia

---

<div class="post-metadata">

**Author:** ![ayarialadin](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@ayarialadin](https://www.thethingsnetwork.org/forum/u/ayarialadin)\
**Post date:** [April 27, 2017, 9:28pm UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/7 "2017-04-27T21:28:37Z")

</div>

yes @celiagarridoh that’s what i meant, do i have to develop the node.js server or it’s already ready and i just have to configure it ?  
Thanks for replaying.

---

<div class="post-metadata">

**Author:** ![celiagarridoh](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/celiagarridoh/32/37579_2.png) [@celiagarridoh](https://www.thethingsnetwork.org/forum/u/celiagarridoh)\
**Post date:** [April 28, 2017, 6:44am UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/8 "2017-04-28T06:44:54Z")

</div>

Yes, you’d have to develop a Node.js server.

1. Install `The Things Network Node.js App SDK` ([https://github.com/TheThingsNetwork/node-app-sdk](https://github.com/TheThingsNetwork/node-app-sdk)), I did it directly in a Raspberry Pi board.

2. Run the example: [https://github.com/TheThingsNetwork/node-app-sdk/blob/master/src/example.js](https://github.com/TheThingsNetwork/node-app-sdk/blob/master/src/example.js) including **your own keys**.

Don’t forget to include the `mqtt-ca certificate` ([https://www.thethingsnetwork.org/docs/applications/mqtt/quick-start.html](https://www.thethingsnetwork.org/docs/applications/mqtt/quick-start.html)) in the same folder as your example.js

Then you should have your server running and printing the uplink packets that your node receives in TTN.

Regards,  
Celia

---

<div class="post-metadata">

**Author:** ![LoraWANSMARU](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/l/7ea924/32.png) [@LoraWANSMARU](https://www.thethingsnetwork.org/forum/u/LoraWANSMARU)\
**Post date:** [April 30, 2017, 10:00am UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/9 "2017-04-30T10:00:00Z")

</div>

Thanks All for the help. Now I can extract data from TTN.  
One more issue is all my packets are not being received on TTN side, also most of the time I get No\_Free\_Channel message.  
Kindly help

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [April 30, 2017, 12:15pm UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/10 "2017-04-30T12:15:45Z")

</div>

No\_free\_channel means you are sending data far too frequently. If possible try a higher data rate, if that is not possible send less frequently. Be aware the TTN fair use policy allows 30 seconds of airtime a day. When your module complains about free channels you are exceeding that limit a number of times.

---

<div class="post-metadata">

**Author:** ![ayarialadin](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@ayarialadin](https://www.thethingsnetwork.org/forum/u/ayarialadin)\
**Post date:** [May 3, 2017, 1:03pm UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/11 "2017-05-03T13:03:16Z")

</div>

@celiagarridoh , thanks a lot, but do i have to install the app in the RPI when it’s supposed to be installed in the TTN server cause i wonna see the packets recieved in the server and not in the gateway, do you get me ?

1. 

and i have a question, does this means that i’m recieving packets in my server from the endnode :  
root@debian:/home/administrator/ttn# ./ttnctl gateways status eui-b827ebfffe388da3  
INFO Discovering Router…  
INFO Connecting with Router…  
INFO Connected to Router  
INFO Received status GatewayID=eui-b827ebfffe388da3

```
       Last seen: 2017-05-03 12:02:55.932595229 -0400 EDT
       Timestamp: 0
   Reported time: 2017-05-03 12:02:37 -0400 EDT
     Description: gnz @ Denges
        Platform: IMST + Rpi
   Contact email: dylan.collaud@gmail.com
      IP Address: 172.31.1.112
 GPS coordinates: (46.525101 6.538970)
             Rtt: not available
              Rx: (in: 6; ok: 6)
              Tx: (in: 0; ok: 0)

```

1. I changed these variables in the exemple js file :  
var region = ‘172.31.1.180’;  
var appId = ‘omniacom4’;  
var accessKey = ‘ttn-account-v2.YlE\_Gt-i\_kz7Fyio2MopBmbo6d2BPftgE5qVb1ueFp4’;

i’ve put the localhost address of the region variable. is that correct cause i’m running a local server ?

but an error appears when i try to execute the file :  
pi@ttn-gateway:~/node-app-sdk/src $ node .

/home/pi/node-app-sdk/src/index.js:3  
const data = require(’./data’);  
^^^^^  
SyntaxError: Use of const in strict mode.  
at Module.\_compile (module.js:439:25)  
at Object.Module.\_extensions…js (module.js:474:10)  
at Module.load (module.js:356:32)  
at Function.Module.\_load (module.js:312:12)  
at Function.Module.runMain (module.js:497:10)  
at startup (node.js:119:16)  
at node.js:906:3

---

<div class="post-metadata">

**Author:** ![celiagarridoh](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/celiagarridoh/32/37579_2.png) [@celiagarridoh](https://www.thethingsnetwork.org/forum/u/celiagarridoh)\
**Post date:** [May 4, 2017, 7:32am UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/12 "2017-05-04T07:32:19Z")

</div>

Hi,

I used a different Raspberry for creating the server, it has nothing to do with the one I used for developing the gateway, sorry if I was confusing. For the server I used a Raspberry with Raspbien and Node.js installed.

About the error, try to check if all the required files are in the directory. However, I was referring to the “example.js” file, not the index.js one.

I think the “region” field is wrong, it should be related to the router TTN is using (for example ‘eu’). Try this and tell me if it helped you.

Regards,  
Celia

---

<div class="post-metadata">

**Author:** ![ayarialadin](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@ayarialadin](https://www.thethingsnetwork.org/forum/u/ayarialadin)\
**Post date:** [May 4, 2017, 11:31am UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/13 "2017-05-04T11:31:13Z")

</div>

> [@celiagarridoh](#):
>
> I think the “region” field is wrong, it should be related to the router TTN is using (for example ‘eu’). Try this and tell me if it helped you.

i’m running a TTN server in my localhost, i wonna know if it works as a region cause i’m running my own router and not connected to the ttn-handler-eu anymore.

This is my router info :  
id: mynetwork-router  
tls: true  
key-dir: router/  
auth-servers:  
ttn-account-v2: “[https://account.thethingsnetwork.org](https://account.thethingsnetwork.org)”

discovery-address: “localhost:1900”  
auth-token: eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE0OTMwMzg2ODAsImlzcyI6ImxvY2FsIiwibmJmIjoxNDkzMDM4NjgwLCJzdWIiOiJteW5ldHdvcmstcm91dGVyIiwidHlwZSI6InJvdXRlci$

router:  
server-address-announce: localhost  
skip-verify-gateway-token: true

---

<div class="post-metadata">

**Author:** ![celiagarridoh](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/celiagarridoh/32/37579_2.png) [@celiagarridoh](https://www.thethingsnetwork.org/forum/u/celiagarridoh)\
**Post date:** [May 4, 2017, 9:37pm UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/14 "2017-05-04T21:37:11Z")

</div>

Hi

I’m sorry, I was referring to extracting data from TTN to your server, but using a TTN router. I’m not sure of how to help you with that, I’m also relatively new with LoRaWAN.

If anyone knows the answer I’d also like to know how to do it 😁

Regards,  
Celia

---

<div class="post-metadata">

**Author:** ![LoraWANSMARU](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/l/7ea924/32.png) [@LoraWANSMARU](https://www.thethingsnetwork.org/forum/u/LoraWANSMARU)\
**Post date:** [May 16, 2017, 10:18am UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/15 "2017-05-16T10:18:23Z")

</div>

Celi,

Can you help me how can I get the Gateway EUI ?

Actually I want to register my Gateway on TTN but unable to find the EUI. I have gone through all the manuals and user guide.

Please Help.  
And thanks for your previous help, now I’m able to extract data from TTN.

Zaheen

---

<div class="post-metadata">

**Author:** ![LoraWANSMARU](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/l/7ea924/32.png) [@LoraWANSMARU](https://www.thethingsnetwork.org/forum/u/LoraWANSMARU)\
**Post date:** [May 28, 2017, 9:11am UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/16 "2017-05-28T09:11:24Z")

</div>

Is there any option to send my data as acknowledgement to LoraModules?

I am using my own server which is getting data regularly from TTN. So I want to send a command(data) to my Lora Devices through TTN. If I use TTN Console I can easily send confirmed message to specific device, is there an API provides this facility so that I can send data from my server?

---

<div class="post-metadata">

**Author:** ![celiagarridoh](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/celiagarridoh/32/37579_2.png) [@celiagarridoh](https://www.thethingsnetwork.org/forum/u/celiagarridoh)\
**Post date:** [May 29, 2017, 11:42am UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/17 "2017-05-29T11:42:45Z")

</div>

Hi @LoraWANSMARU,

1. Sorry for that long time, I didn’t have Internet access. I’m not quite sure of where did I find the EUI, I’m going to take a look to see if I find it so I can help you, that shouldn’t be a problem I hope…

2. Yes, I think there’s a way to do that, but it may not be recommendable to send many downlink messages from your server (using TTN) to your nodes.

According to [https://www.thethingsnetwork.org/wiki/LoRaWAN/Limitations:](https://www.thethingsnetwork.org/wiki/LoRaWAN/Limitations:)

> Downlink messages should be avoided if possible, and if you send downlink, keep the payload small

However, what client are you using in your server?

Regards,  
Celia

---

<div class="post-metadata">

**Author:** ![BoRRoZ](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/borroz/32/44234_2.png) [@BoRRoZ](https://www.thethingsnetwork.org/forum/u/BoRRoZ)\
**Post date:** [May 29, 2017, 12:05pm UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/18 "2017-05-29T12:05:24Z")

</div>

meet[Celia](https://www.thethingsnetwork.org/forum/t/the-library-basement-part-2/5976/111)😊

---

<div class="post-metadata">

**Author:** ![LoraWANSMARU](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/l/7ea924/32.png) [@LoraWANSMARU](https://www.thethingsnetwork.org/forum/u/LoraWANSMARU)\
**Post date:** [May 29, 2017, 12:07pm UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/19 "2017-05-29T12:07:14Z")

</div>

Hi celiagarridoh,

I did not understand your term ‘Client’. I just want to send data to one of my Lora Device through TTN from my server.

---

<div class="post-metadata">

**Author:** ![celiagarridoh](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/celiagarridoh/32/37579_2.png) [@celiagarridoh](https://www.thethingsnetwork.org/forum/u/celiagarridoh)\
**Post date:** [May 29, 2017, 12:53pm UTC](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920/20 "2017-05-29T12:53:09Z")

</div>

> [@LoraWANSMARU](#):
>
> I am using my own server which is getting data regularly from TTN

How did you implement your server? For example, I used the Node.js client library for that, taking a look at the library you’ll see how to send downlink messages, am I right?

[Next page](https://www.thethingsnetwork.org/forum/t/extracting-data-from-ttn-to-my-server/6920.md?page=2)
