Skip to content

webdock-io/python-sdk

Repository files navigation

Webdock API Python SDK

A type-safe Python wrapper for the Webdock.io API.

Documentation

Full API documentation is available at api.webdock.io

Installation

pip install webdock

Quick Start

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()

Response Structure

All API operations return a response object with two main components:

  • body: Contains the actual API response data
  • headers: Contains HTTP headers, including tracking information like x_callback_id

Example Usage

# 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")

Backward Compatibility

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.

Support

About

Python SDK Library / Wrapper for the Webdock API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages