Hey there, fellow developer! Ready to supercharge your workflow automation? Let's dive into building a Process Street API integration using Python. This guide will walk you through the essentials, helping you leverage the power of Process Street in your applications. Buckle up!
Before we jump in, make sure you've got these basics covered:
requests
library (pip install requests
)Got all that? Great! Let's get coding.
First things first, let's get you authenticated:
import requests API_KEY = 'your_api_key_here' BASE_URL = 'https://api.process.st/api/v1' headers = { 'Authorization': f'Bearer {API_KEY}', 'Content-Type': 'application/json' }
Pro tip: Keep that API key safe! Consider using environment variables for added security.
Let's start with some basic requests to get a feel for the API:
# GET request response = requests.get(f'{BASE_URL}/workflows', headers=headers) print(response.json()) # POST request new_workflow = {'name': 'My Awesome Workflow'} response = requests.post(f'{BASE_URL}/workflows', headers=headers, json=new_workflow) print(response.json())
Remember to always check the response status and handle errors gracefully!
Now, let's get our hands dirty with some workflow operations:
# Get all workflows workflows = requests.get(f'{BASE_URL}/workflows', headers=headers).json() # Get a specific workflow workflow_id = 'your_workflow_id' workflow = requests.get(f'{BASE_URL}/workflows/{workflow_id}', headers=headers).json() # Create a new workflow new_workflow = { 'name': 'New Python Workflow', 'description': 'Created via API' } created_workflow = requests.post(f'{BASE_URL}/workflows', headers=headers, json=new_workflow).json()
Time to put those workflows to work:
# Start a checklist run run_data = { 'workflowId': 'your_workflow_id', 'name': 'API Generated Run' } new_run = requests.post(f'{BASE_URL}/checklist-runs', headers=headers, json=run_data).json() # Update run status run_id = new_run['id'] update_data = {'status': 'completed'} updated_run = requests.patch(f'{BASE_URL}/checklist-runs/{run_id}', headers=headers, json=update_data).json()
Let's not forget about those all-important tasks:
# Get task info task_id = 'your_task_id' task = requests.get(f'{BASE_URL}/tasks/{task_id}', headers=headers).json() # Update task status update_data = {'status': 'completed'} updated_task = requests.patch(f'{BASE_URL}/tasks/{task_id}', headers=headers, json=update_data).json() # Add a comment comment_data = {'body': 'Great job on this task!'} new_comment = requests.post(f'{BASE_URL}/tasks/{task_id}/comments', headers=headers, json=comment_data).json()
Want to stay in the loop? Set up some webhooks:
# Create a webhook webhook_data = { 'url': 'https://your-webhook-endpoint.com', 'events': ['checklist.run.completed', 'task.completed'] } new_webhook = requests.post(f'{BASE_URL}/webhooks', headers=headers, json=webhook_data).json() # Don't forget to set up an endpoint to handle these events!
As you build out your integration, keep these tips in mind:
And there you have it! You're now equipped to build powerful Process Street integrations with Python. Remember, this is just scratching the surface – there's so much more you can do with the API.
For more in-depth information and advanced features, check out the official Process Street API documentation.
Happy coding, and may your workflows be ever efficient!
Want to see it all in action? Check out our GitHub repository for full code examples and additional resources.
Now go forth and automate all the things! 🚀