You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+89-79Lines changed: 89 additions & 79 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,84 +1,109 @@
1
-
# Blue Button API SDK (Python)
1
+
# Python SDK for Blue Button 2.0 API
2
+
This Python software development kit (SDK) provides tools and resources for developers integrating with the [CMS Blue Button 2.0 (BB2.0) API](https://bluebutton.cms.gov/developers/).
2
3
3
-
# Table of contents
4
4
5
-
1.[Descritpion](#description)
6
-
2.[Installation](#installation)
7
-
3.[Configuration](#configuration)
8
-
4.[Usages: Obtain Access Grant, Probe Scope, and Access Data](#usages)
9
-
5.[A Complete Sample App](#samples)
10
-
6.[API Versions and Environments](#versions_and_environments)
This is an SDK for interacting with the [CMS Blue Button 2.0 API](https://bluebutton.cms.gov/developers/).
16
-
The API allows applications to obtain a beneficiary's (who has login account with medicare.gov) grant
17
-
to access their medicare claims data - through the OAuth 2.0 [(RFC 6749)](https://datatracker.ietf.org/doc/html/rfc6749) authorization flow.
18
17
19
-
By using the SDK, the development of applications accessing the Blue Button 2.0 API can be greatly simplified.
18
+
## Prerequisites <aname="prerequisites"></a>
19
+
20
+
You'll need a sandbox account and sample access token to access data from the Blue Button 2.0 API.
21
+
22
+
To learn how to create a sandbox account and generate a sample access token, see **[Try the API](https://bluebutton.cms.gov/developers/#try-the-api)**.
20
23
21
-
Note: In following OAuth 2.0 best practices, the PKCE extension [(RFC 7636)](https://datatracker.ietf.org/doc/html/rfc7636) is always enabled.
| environment | "SANDBOX" or "PRODUCTION" | BB2 API environment (default="SANDBOX") |
45
-
| version | 1 or 2 | BB2 API version (default=2) |
46
-
| client_id | "foo" | oauth2 client id of the app |
47
-
| client_secret | "bar" | oauth2 client secret of the app |
48
-
| callback_url | "https://www.fake.com/callback"| oauth2 callback URL of the app |
44
+
### Access Token Refresh on Expire
45
+
SDK FHIR requests check whether the access token is expired before the data end point call. By default, if the access token is expired, the token in the current token object refreshes. Disable token refresh by setting `token_refresh_on_expire` to `false`.
49
46
50
-
For application registration and client id and client secret, please refer to:
51
-
[Blue Button 2.0 API Docs - Try the API](https://bluebutton.cms.gov/developers/#try-the-api)
47
+
### FHIR Requests Retry Settings
52
48
53
-
Auth Token Refresh on Expire:
49
+
Retry is enabled by default for FHIR requests. The folllowing parameters are available for exponential back off retry algorithm.
54
50
55
-
SDK FHIR requests will check if the access token is expired before the data end point call, if the access token is expired, then a token refresh is performed with the refresh token in the current auth token object, this behavior can be disabled by setting configuration parameter as below:
51
+
| Retry parameter | Value (default) | Description |
|`backoff_factor`|`5`| Backoff factor in seconds |
54
+
|`total `|`3`| Max retries |
55
+
|`status_forcelist`|[`500`, `502`, `503`, `504`]| Error response codes to retry on |
56
56
57
-
"token_refresh_on_expire": false
57
+
The exponential backoff factor (in seconds) is used to calculate interval between retries using the formula `backoff_factor * (2 ** (i - 1))` where `i` starts from 0.
58
58
59
-
By default, token_refresh_on_expire is true.
59
+
Example:
60
60
61
-
FHIR requests retry:
61
+
A`backoff_factor` of 5 seconds generates the wait intervals: 2.5, 5, 10, ...
62
62
63
-
Retry is enabled by default for FHIR requests, retry_settings: parameters for exponential back off retry algorithm
There are three ways to configure the SDK when instantiating a `BlueButton` class instance.
80
105
81
-
*Python Dictionary:
106
+
### Python Dictionary
82
107
- A dictionary of configuration key:value pairs can be used.
83
108
- Configuration values can be provided from your own application's configuration method.
84
109
- Example code:
@@ -96,7 +121,7 @@ There are three ways to configure the SDK when instantiating a `BlueButton` clas
96
121
}
97
122
}
98
123
```
99
-
*JSON config file:
124
+
### JSON config file
100
125
- This is using a configuration file that is in a JSON format.
101
126
- This is stored in a local file.
102
127
- The default location is in the current working directory with a file name: .bluebutton-config.json
@@ -120,7 +145,7 @@ There are three ways to configure the SDK when instantiating a `BlueButton` clas
120
145
}
121
146
```
122
147
123
-
*YAML config file:
148
+
### YAML config file
124
149
- This is using a configuration file that is in a YAML format.
125
150
- This is stored in a local file.
126
151
- The default location is in the current working directory with a file name: .bluebutton-config.yaml
@@ -139,7 +164,7 @@ There are three ways to configure the SDK when instantiating a `BlueButton` clas
139
164
140
165
## Sample Usage: Obtain Access Grant, Probe Scope, and Access Data <aname="usages"></a>
141
166
142
-
Below are psuedo code snippets showing SDK used withpython server andflask.
167
+
Below are code snippets showing the SDK used with Python server and Flask.
143
168
144
169
```python
145
170
from flask import Flask
@@ -257,39 +282,24 @@ if __name__ == '__main__':
257
282
app.run(debug=True, host='0.0.0.0', port=3001)
258
283
```
259
284
260
-
## A Complete Sample App <a name="samples"></a>
261
-
262
-
A Python React sample app can be found at:
263
-
[CMS Blue Button Python Sample App](https://github.com/CMSgov/bluebutton-sample-client-python-react)
264
-
265
-
## API Versions and Environments <a name="versions_and_environments"></a>
266
-
267
-
Can be selected for environments: PRODUCTIONandSANDBOX.
285
+
## Sample App <aname="samples"></a>
268
286
269
-
The Blue Button APIis available in versions v1 and v2.
287
+
For a complete Python React sample app, see [CMS Blue Button Python Sample App](https://github.com/CMSgov/bluebutton-sample-client-python-react).
270
288
271
-
The data served from v1 isinFHIRSTU2format, and data from v2 isinFHIR R4 format.
272
289
273
-
An application's target environment and API version can be set in the SDK configuration as shown by the JSON example below:
290
+
## SDK Development <aname="sdk_devel"></a>
274
291
275
-
```json
276
-
{
277
-
"clientId": "foo",
278
-
"clientSecret": "bar",
279
-
"callbackUrl": "https://www.fake.com/",
280
-
"version": "2",
281
-
"environment": "PRODUCTION"
282
-
}
283
-
```
292
+
Documentation for BlueButton 2.0 team members and others developing the SDK can be found at [README-sdk-dev.md](./README-sdk-dev.md).
284
293
285
-
If not included, the default API version is v2, and the default environment isSANDBOX.
294
+
## About the Blue Button 2.0 API <aname="about"></a>
286
295
287
-
Web location of the environments:
296
+
The [Blue Button 2.0 API](https://bluebutton.cms.gov/) provides Medicare enrollee claims data to applications using the [OAuth2.0 authorization flow](https://datatracker.ietf.org/doc/html/rfc6749). We aim to provide a developer-friendly, standards-based API that enables people with Medicare to connect their claims data to the applications, services, and research programs they trust.
The CMS Blue Button 2.0 Python SDK is licensed under the Creative Commons Zero v1.0 Universal. For more details, see [License](https://github.com/CMSgov/cms-bb2-python-sdk/blob/main/LICENSE).
*Note: We do our best to keep our SDKs up to date with vulnerability patching, but you are responsible for conducting your own review and testing before implementation.*
292
302
293
-
## SDK Development <a name="sdk_devel"></a>
303
+
## Help and Support <aname="help"></a>
294
304
295
-
Documentation forBB2 team members and others developing the SDK can be found here: [README-sdk-dev.md](./README-sdk-dev.md)
305
+
Got questions? Need help troubleshooting? Want to propose a new feature? Contact the Blue Button 2.0 team and connect with the community in our [Google Group](https://groups.google.com/forum/#!forum/Developer-group-for-cms-blue-button-api).
0 commit comments