API stability uses the MongoDB Stable API as a versioned compatibility contract. Setting an API version keeps supported command behavior consistent while MongoDB servers, drivers, and Atlas clusters are upgraded, reducing unexpected application changes. section 4.14 section 21.4
Configure the Stable API deliberately:
- Specify apiVersion in connection settings so the server applies the selected API protocols and behaviors. section 4.14
- Use the contract to preserve backward compatibility and insulate applications from deprecations or removals in newer server versions. section 4.14
- Check command coverage before relying on the contract; API version 1 is currently the only supported version, with listed commands and version availability. section 4.14
PyMongo connection
Create a MongoClient with server_api=ServerApi('1'), then use the client for normal database operations. PyMongo supports this Stable API feature from driver version 3.12 and connects it to MongoDB Server version 5 and later. section 3.6.1
mongosh "mongodb+srv://YOUR_CLUSTER.YOUR_HASH.mongodb.net/" \ --apiVersion API_VERSION --username USERNAME –-password PASSWD
The mongosh command shows where to place --apiVersion when connecting to an Atlas deployment through an SRV connection string. section 3.2.1
