# Atdpy: derive safe JSON interfaces for Python

**URL:** <https://discuss.ocaml.org/t/atdpy-derive-safe-json-interfaces-for-python/9544>\
**Category:** Ecosystem\
**Tags:** metaprogramming, atd, atdgen, announce\
**Created:** [March 21, 2022, 6:50pm UTC](https://discuss.ocaml.org/t/atdpy-derive-safe-json-interfaces-for-python/9544 "2022-03-21T18:50:54Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![mjambon](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mjambon/32/6180_2.png) [@mjambon](https://discuss.ocaml.org/u/mjambon)\
**Post date:** [March 21, 2022, 6:50pm UTC](https://discuss.ocaml.org/t/atdpy-derive-safe-json-interfaces-for-python/9544/1 "2022-03-21T18:50:54Z")

</div>

On behalf of the ATD team, I’d like to announce atdpy, which is part of the release 2.3.x of the ATD tools. For now, the best installation method with via opam:

```auto
$ opam install atdpy

```

Atdpy is a new backend for [ATD](https://github.com/ahrefs/atd). It takes a collection of type definitions and derives Python classes with mypy type annotations that validate the JSON data.

A [short introduction](https://atd.readthedocs.io/en/latest/atdpy.html) is included in the documentation.

Use cases:

- Safe communication with another program that also uses an ATD interface. Other supported languages are OCaml (including Bucklescript), Java, and Scala.
- Need for [mostly] type-safe Python methods via mypy.
- Need for a good Python API to communicate with an OCaml executable or service.
- Need for sum types (variants, algebraic data types, tagged unions). ATD sum types are ordinary types that include pure enums.

Atdpy was developed as part of our work on [Semgrep](https://semgrep.dev/) at [r2c](https://r2c.dev/). Many thanks to @mseri for his massive help during the opam release of the 7 ATD packages, and to the Ahrefs folks and @Khady in particular for supporting the project.

---

_[View the full topic](https://discuss.ocaml.org/t/atdpy-derive-safe-json-interfaces-for-python/9544)._
