IBM Cloudant Python SDK is a client library that interacts with the
IBM Cloudant APIs.
Disclaimer: This library is still a 0.x release. We do consider this
library production-ready and capable, but there are still some
limitations we’re working to resolve, and refinements we want to
deliver. We are working really hard to minimise the disruption from
now until the 1.0 release, but there may still be some changes that
impact applications using this SDK. For now, be sure to pin versions
to avoid surprises.
The IBM Cloudant Python SDK allows developers to programmatically
interact with IBM Cloudant
with the help of the ibmcloudant package.
Features
The purpose of this Python SDK is to wrap most of the HTTP request APIs
provided by Cloudant and supply other functions to ease the usage of Cloudant.
This SDK should make life easier for programmers to do what’s really important
to them: developing software.
Reasons why you should consider using Cloudant Python SDK in your
project:
The following section describes the different authentication types and provides environment variable examples.
Examples for other configuration methods are available by following the provided links.
Authentication
Consult the authentication document
for comprehensive details of all the available authentication methods and how to configure them with environment settings
or programmatically.
Quick start for Cloudant with an IAM API key:
CLOUDANT_URL=https://~replace-with-cloudant-host~.cloudantnosqldb.appdomain.cloud # use your own Cloudant public or private URL
CLOUDANT_APIKEY=a1b2c3d4e5f6f1g4h7j3k6l9m2p5q8s1t4v7x0z3 # use your own IAM API key
Quick start for Apache CouchDB with a username/password session:
CLOUDANT_AUTH_TYPE=COUCHDB_SESSION
CLOUDANT_URL=https://~replace-with-your-unique-host~.example:6984 # use your CouchDB URL
CLOUDANT_USERNAME=username # replace with your username
CLOUDANT_PASSWORD=password # replace with your password
Automatic retries
The SDK supports a generalized retry feature that can automatically retry on common errors.
The automatic retries section has details on how to enable the retries with default values and customize the retries programmatically or with external configuration.
Request timeout configuration
No request timeout is defined, but a 2.5m read and a 60s connect timeout are set by default. Be sure to set a request timeout appropriate to your application usage and environment.
The request timeout section contains details on how to change the value.
Note: System settings may take precedence over configured timeout values.
Code examples
Quick start example to list all databases (assumes environment variable authentication):
# section: code
from ibmcloudant.cloudant_v1 import CloudantV1
service = CloudantV1.new_instance()
response = service.get_all_dbs().get_result()
print(response)
More tutorial examples for creating a database
and document create, read, update and delete operations.
For endpoints that read or write document content it is possible to bypass
usage of the built-in object with byte streams.
Depending on the specific SDK operation it may be possible to:
accept a user-provided byte stream to send to the server as a request body
return a byte stream of the server response body to the user
Request byte stream can be supplied for arguments that accept the BinaryIO type.
For these cases you can pass this byte stream directly to the HTTP request body.
Response byte stream is supported in functions with the suffix of _as_stream.
The returned byte stream allows the response body to be consumed
without triggering JSON unmarshalling that is typically performed by the SDK.
The update document section
contains examples for both request and response byte stream cases.
The API reference contains further examples of using byte streams.
They are titled "Example request as stream" and are initially collapsed.
Expand them to see examples of:
Cloudant docs:
The official documentation page for Cloudant.
Cloudant blog:
Many useful articles about how to optimize Cloudant for common problems.
Questions
If you are having difficulties using this SDK or have a question about the
IBM Cloud services, ask a question on
Stack Overflow.
Issues
If you encounter an issue with the project, you are welcome to submit a
bug report.
Before you submit a bug report, search for
similar issues and review the
KNOWN_ISSUES file to verify that your issue hasn't been reported yet.
Please consult the security policy before opening security related issues.
Versioning and LTS support
This SDK follows semantic versioning with respect to the definition of user facing APIs.
This means under some circumstances breaking changes may occur within a major or minor version
of the SDK related to changes in supported language platforms.
The SDK is supported on the available LTS releases of the language platform.
The LTS language versions are listed in the prerequisites:
Incompatible changes from new language versions are not added to the SDK
until they are available in the minimum supported language version.
When language LTS versions move out of support the following will happen:
Existing SDK releases will continue to run on obsolete language versions, but will no longer be supported.
The minimum language version supported by the SDK will be updated to the next available LTS.
New language features may be added in subsequent SDK releases that will cause breaking changes
if the new releases of the SDK are used with older, now unsupported, language levels.
Open source at IBM
Find more open source projects on the IBM GitHub page.