How I Automate My Freelance Workflow with Python
As a freelance developer, I've learned that automation is key to increasing productivity and reducing the time spent on repetitive tasks. In this article, I'll show you how I use Python to automate my freelance workflow, from project management to invoicing.
Project Management Automation
I use a combination of Python scripts and APIs to automate my project management workflow. One of the tools I use is Trello, which has a robust API that allows me to create, update, and delete boards, lists, and cards programmatically.
Here's an example of how I use the Trello API to create a new board and list for each new project:
import requests
# Trello API credentials
api_key = "YOUR_API_KEY"
api_token = "YOUR_API_TOKEN"
# Create a new board
board_name = "New Project"
response = requests.post(
f"https://api.trello.com/1/boards/?key={api_key}&token={api_token}&name={board_name}"
)
board_id = response.json()["id"]
# Create a new list
list_name = "To-Do"
response = requests.post(
f"https://api.trello.com/1/lists/?key={api_key}&token={api_token}&name={list_name}&idBoard={board_id}"
)
list_id = response.json()["id"]
This script creates a new board and list for each new project, saving me time and reducing the risk of human error.
Time Tracking Automation
Accurate time tracking is essential for freelancers, as it allows us to bill clients accurately and efficiently. I use a Python script to automate my time tracking workflow, which integrates with my project management tool (Trello) and my invoicing tool (Wave).
Here's an example of how I use the Trello API to track time spent on each task:
import requests
import datetime
# Trello API credentials
api_key = "YOUR_API_KEY"
api_token = "YOUR_API_TOKEN"
# Get the current card
card_id = "CURRENT_CARD_ID"
response = requests.get(
f"https://api.trello.com/1/cards/{card_id}?key={api_key}&token={api_token}"
)
card_data = response.json()
# Get the start time
start_time = datetime.datetime.now()
# Track time spent on the task
while True:
# Get user input
user_input = input("Press 'q' to quit: ")
if user_input == "q":
break
# Get the end time
end_time = datetime.datetime.now()
# Calculate the time spent
time_spent = end_time - start_time
# Update the card with the time spent
response = requests.put(
f"https://api.trello.com/1/cards/{card_id}?key={api_key}&token={api_token}",
json={"desc": f"Time spent: {time_spent}"}
)
This script tracks the time spent on each task and updates the corresponding Trello card with the time spent.
Invoicing Automation
Invoicing is a crucial part of the freelance workflow, as it allows us to get paid for our work. I use a Python script to automate my invoicing workflow, which integrates with my project management tool (Trello) and my time tracking tool (above script).
Here's an example of how I use the Wave API to create a new invoice:
python
import requests
# Wave API credentials
api_key = "YOUR_API_KEY"
api_token = "YOUR_API_TOKEN"
# Get the client data
client_id = "CLIENT_ID"
client_data = requests.get(
f"https://api.waveapps.com/businesses/{client_id}/customers",
headers={"Authorization": f"Bearer {api_token}"}
).json()
# Get the invoice
Top comments (0)