How to fetch the single-layer structure from the MP database through the code

Dear All, I obtained some structures I needed in batches from the MP database, but because they were stacked block materials, I wanted to write a code to capture the atomic coordinates of different layers. I tried a lot of methods but it didn’t work out very well. How can I extract the single layer structure from the code?