The pyoai package enables high-level access to an OAI-PMH metadata repository and also implements a framework for quickly creating OAI-PMH compliant servers. Arbitrary repositories can be accessed and harvested using an easy to use Python-based API. It has built-in support for the default Dublin Core metadata set (oai_dc). It can also be easily extended with support for other metadata sets using a simple declarative system based on industry-standard xpath expressions. The same simple Python API used for harvesting can be implemented by the programmer to set up a new OAI-PMH compliant server.