- Print
- DarkLight
Call the Partner API
- Print
- DarkLight
Most of the API calls for the Backblaze Partner API accept a POST with JSON data, and return JSON data. The code samples for each of the calls show how to do that in a variety of languages.
Construct a URL
For most calls, you construct the URL by combining the following elements:
- The
groupsApiUrl
that is returned by theb2_authorize_account
operation. /b2api
/v
versionNumber/
apiName
The version number specifies which version of the API that you want to call. The API name indicates which API entry point that you want to call. For Partner API calls, you should specify version three. The resulting URL looks like the following example when you call the b2_list_groups
operation:
https://api123.backblazeb2.com/b2api/v3/b2_list_groups
Authorize an Account
Calling b2_authorize_account
is special because the API URL is fixed, https://api.backblazeb2.com, so the full URL looks like the following example:
https://api.backblazeb2.com/b2api/v3/b2_authorize_account
POST JSON -> JSON
This is the normal case for the Partner API. You create a request as a JSON object, POST in to the Partner API service, and get a JSON object in the response.
The following example uses cURL on the command-line:
ACCOUNT_AUTH_TOKEN=... # Comes from the b2_authorize_account call
API_URL=... # Comes from the b2_authorize_account call
curl -H "Authorization: $ACCOUNT_AUTH_TOKEN" \
-d '{}' \
"$API_URL/b2api/v3/b2_list_groups"
The following example is returned:
{
"groups": [
{
"groupId": "10101",
"groupName": "My Business Group",
"groupProducts": ["STORAGE"],
"totalBalanceDue": 0.0,
"billingState": "GOOD",
"groupStats": {
"memberCount": 100,
"createdTimestamp": "d20211120_m121212",
"groupStatsAsOfTimestamp": "d20211220_m000000"
},
"b2Stats": {
"bucketCount": 100,
"b2BytesStoredCount": 1000000,
"b2FilesStoredCount": 150,
"b2StatsAsOfTimestamp": "d20211220_m000000"
},
"revision": 1
},
{
"groupId": "10102",
"groupName": "My Business Group 2",
"groupProducts": ["STORAGE"],
"totalBalanceDue": 0.0,
"billingState": "GOOD",
"groupStats": {
"memberCount": 120,
"createdTimestamp": "d20211120_m121212",
"groupStatsAsOfTimestamp": "d20211220_m000000"
},
"b2Stats": {
"bucketCount": 30,
"b2BytesStoredCount": 1000000,
"b2FilesStoredCount": 150,
"b2StatsAsOfTimestamp": "d20211220_m000000"
},
"revision": 1
}
]
}
GET -> JSON
All API calls that accept POST-ed JSON also accept the parameters as URL query parameters. This is much more convenient for ad-hoc requests that you type by hand, and for using in a browser.
The following request is equivalent to the one above:
ACCOUNT_AUTH_TOKEN=... # Comes from the b2_authorize_account call
API_URL=... # Comes from the b2_authorize_account call
curl -H "Authorization: $ACCOUNT_AUTH_TOKEN" \
"$API_URL/b2api/v3/b2_list_groups"