# Python API - downlink\_callback

**URL:** <https://www.thethingsnetwork.org/forum/t/python-api-downlink-callback/40573>\
**Category:** Application Development\
**Created:** [October 14, 2020, 2:36pm UTC](https://www.thethingsnetwork.org/forum/t/python-api-downlink-callback/40573 "2020-10-14T14:36:55Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [October 15, 2020, 8:48am UTC](https://www.thethingsnetwork.org/forum/t/python-api-downlink-callback/40573/7 "2020-10-15T08:48:01Z")

</div>

> [@goodrun](#):
>
> `mqttc.subscribe('+/devices/+/down')`

You’ll need `+/devices/+/events/down/sent` (or a broader wildcard, such as `#`).

> [@goodrun](#):
>
> want to store uplink and downlink data to a csv

Do yourself a favor for future debugging and store _all_ events you can get through MQTT. Also, store the time, and the topic you’re getting it on:

> [@MQTT in Node-RED \[HowTo\]](https://www.thethingsnetwork.org/forum/t/mqtt-in-node-red-howto/39909/1):
>
> For logging, one may want to ensure the topic and time are always included:
> 
> ```javascript
> // A file node only saves msg.payload, but +/+/+/events/down/scheduled
> // holds no details about application, device nor timestamp in the
> // MQTT payload, but only: 
> // {"message": {"port": 1, "payload_raw": "BA=="}}
> // Same goes for TTN-published errors:
> // {"error": "Unable to decode payload fields: Internal error: ..."}}
> // So, ensure the topic and time are also saved into the log file:
> msg.payload = {
> topic: msg.topic,
> timestamp: new Date().toISOString(),
> payload: msg.payload,
> error: msg.error
> }
> 
> return msg;
> 
> ```

---

_[View the full topic](https://www.thethingsnetwork.org/forum/t/python-api-downlink-callback/40573)._
