You can get the Version Count of a Bin using the Bin Versions Count API.
Root
https://api.jsonbin.io/v3
Route (READ a specific Bin)
/b/<BIN_ID>/versions/count
Request Type
GET
Request Headers
Header | Value | Required |
X-Master-Key | <YOUR_API_KEY> | No |
X-Master-Key
X-Master-Key needs to be passed in-order to get the Version count for the Private Bin. In-order to get the key, you need to sign-up and navigate to API Keys page.
Basic Code Samples
curl -v\
-H "X-Master-key: <YOUR_API_KEY>" \
--request GET \
https://api.jsonbin.io/v3/b/<BIN_ID>/versions/count
let req = new XMLHttpRequest();
req.onreadystatechange = () => {
if (req.readyState == XMLHttpRequest.DONE) {
console.log(req.responseText);
}
};
req.open("GET", "https://api.jsonbin.io/v3/b/<BIN_ID>/versions/count", true);
req.setRequestHeader("X-Master-Key", "<YOUR_API_KEY>");
req.send();
import requests
url = 'https://api.jsonbin.io/v3/b/<BIN_ID>/versions/count'
headers = {
'X-Master-Key': '<YOUR_API_KEY>'
}
req = requests.get(url, json=None, headers=headers)
print(req.text)
require 'net/http'
require 'json'
uri = URI("https://api.jsonbin.io/v3/b/<BIN_ID>/versions/count")
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
req = Net::HTTP::Post.new(uri)
req['X-Master-Key'] = '<YOUR_API_KEY>'
http.request()
end
puts res.body
Request Response
Success 200
{
"metadata": {
"id": "<BIN_ID>",
"versionCount": 0,
"private": true
}
}
Error 400, 401, 403
{
"message": "<ERROR_MESSAGE>"
}
Status Code | Error Message |
---|---|
400 Bad Request |
Invalid Bin Id provided |
404 Not Found |
Bin not found or it doesn't belong to your account |
403 Not Found |
Bins not associated to any user are now blocked. Contact the admin at https://jsonbin.io/contact for further info |
401 Unauthorised |
You need to pass X-Master-Key in the header to get version count for the private bin |
401 Unauthorised |
X-Master-Key is invalid or the bin doesn't belong to your account |
401 Unauthorised |
Bin not associated to any user account |
403 Forbidden |
Requests exhausted. Buy additional requests at https://jsonbin.io/pricing |