A type-safe Python wrapper for the Webdock.io API.
Full API documentation is available at api.webdock.io
pip install webdock
Each operation returns both body and headers that you can access using the get()
method:
import time
from webdock import webdock
from requests import RequestException
def main():
# Initialize client with your API token
client = webdock.Webdock("your_api_token_here")
try:
# Create a new server
server = client.servers.create(
imageSlug="foo",
locationId="foo",
name="test-server",
profileSlug="foo",
)
# Access server data from response body
aliases = server.get("body").get("aliases")
print(f"Server aliases: {aliases}")
# Access callback ID from headers to track provision operation state
callback_id = server.get("headers").get("x_callback_id")
print(f"Callback ID: {callback_id}")
except RequestException as e:
print(f"API request failed: {e}")
if __name__ == "__main__":
main()
All API operations return a response object with two main components:
body
: Contains the actual API response dataheaders
: Contains HTTP headers, including tracking information likex_callback_id
# Get server information
server_info = server.get("body")
server_name = server_info.get("name")
server_status = server_info.get("status")
# Track operations using headers
callback_id = server.get("headers").get("x_callback_id")
The legacy package is still available but deprecated. You can import it for existing projects:
import time
from oldwebdock.webdock import Webdock
from requests import RequestException
def main():
client = Webdock("your_api_token_here")
try:
# Create webhook (legacy syntax)
webhook = client.create_hook(
hookType="foo",
hookValue="https://your-webhook-url.com"
)
except RequestException as e:
print(f"Request failed: {e}")
if __name__ == "__main__":
main()
⚠️ Deprecation Notice: legacy package is now deprecated. Please migrate to the new SDK for continued support and updates.