DEV Community

Caper B
Caper B

Posted on

How I Automate My Freelance Workflow with Python

How I Automate My Freelance Workflow with Python

As a freelance developer, I've learned that automation is key to increasing productivity and efficiency. In this article, I'll share how I use Python to automate my freelance workflow, from project management to invoicing and payment tracking.

Introduction to Automation

Automation is the process of using software or machines to perform tasks that would otherwise be done manually. In the context of freelancing, automation can help with tasks such as:

  • Project management: creating and assigning tasks, tracking progress, and setting deadlines
  • Time tracking: logging hours worked on projects and generating reports
  • Invoicing and payment tracking: creating and sending invoices, tracking payments, and following up on overdue invoices
  • Client communication: sending automated emails or messages to clients with updates on project status

Step 1: Project Management with Trello and Python

I use Trello to manage my projects and tasks. Trello provides an API that allows me to interact with my boards and cards programmatically. I use the requests library in Python to make API calls to Trello.

import requests

# Set API key and token
api_key = "your_api_key"
token = "your_token"

# Set board ID
board_id = "your_board_id"

# Get all cards on the board
response = requests.get(f"https://api.trello.com/1/boards/{board_id}/cards", 
                          params={"key": api_key, "token": token})

# Print the names of all cards
for card in response.json():
    print(card["name"])
Enter fullscreen mode Exit fullscreen mode

Step 2: Time Tracking with Harvest and Python

I use Harvest to track my time and generate reports. Harvest provides an API that allows me to interact with my time entries programmatically. I use the requests library in Python to make API calls to Harvest.

import requests

# Set API key and account ID
api_key = "your_api_key"
account_id = "your_account_id"

# Set project ID and task ID
project_id = "your_project_id"
task_id = "your_task_id"

# Log time entry
response = requests.post(f"https://api.harvestapp.com/v2/time_entries", 
                          headers={"Authorization": f"Bearer {api_key}", 
                                   "Harvest-Account-Id": account_id, 
                                   "Content-Type": "application/json"}, 
                          json={"project_id": project_id, "task_id": task_id, "hours": 2})

# Print the ID of the new time entry
print(response.json()["id"])
Enter fullscreen mode Exit fullscreen mode

Step 3: Invoicing and Payment Tracking with Stripe and Python

I use Stripe to create and send invoices, as well as track payments. Stripe provides an API that allows me to interact with my invoices and payments programmatically. I use the stripe library in Python to make API calls to Stripe.

import stripe

# Set API key
stripe.api_key = "your_api_key"

# Create a new invoice
invoice = stripe.Invoice.create(customer="your_customer_id", 
                                 billing_address={
                                     "name": "John Doe", 
                                     "address": {
                                         "line1": "123 Main St", 
                                         "city": "Anytown", 
                                         "state": "CA", 
                                         "postal_code": "12345", 
                                         "country": "US"
                                     }
                                 }, 
                                 items=[
                                     {"price_data": {
                                         "currency": "usd", 
                                         "product_data": {
                                             "name": "My Product"
                                         }, 
                                         "unit_amount": 1000
                                     }}
                                 ])

# Print the ID of the new invoice
print(invoice["id"])
Enter fullscreen mode Exit fullscreen mode

Monetization Angle

By automating my freelance workflow, I'm able to save time and increase my earning potential. I can

Top comments (0)